> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. # Segment > Learn how to add Segment analytics to your Fern documentation. Step-by-step guide to configure your Segment writeKey. Integrate Segment to collect analytics and route user data to your preferred analytics destinations. #### Get your Segment writeKey In your Segment workspace, navigate to your Source, then go to **Settings > API Keys** and copy the **Write Key**. #### Add Segment to \`docs.yml\` In your `docs.yml` file, add the Segment writeKey: #### docs.yml ```yaml analytics: segment: write-key: ${SEGMENT_WRITE_KEY} # scans environment variable ``` #### Provide the write key at publish time The `${SEGMENT_WRITE_KEY}` syntax reads the key from an environment variable at publish time, so the variable must be present in whatever environment runs `fern generate --docs`. When you publish with a GitHub Actions workflow, map the secret into the publish step's `env`: **`.github/workflows/publish-docs.yml`** ```yaml .github/workflows/publish-docs.yml {4} - name: Publish Docs env: FERN_TOKEN: ${{ secrets.FERN_TOKEN }} SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }} run: | npm install -g fern-api fern generate --docs ``` > Learn how to add Segment analytics to your Fern documentation. Step-by-step guide to configure your Segment writeKey.