---
title: Google Analytics Integration
description: Add Google Analytics 4 (GA4) to your documentation site. Requires a measurement ID starting with G-.
---

Add Google Analytics 4 to your documentation site to understand how users interact with your content.

<Info>
Google Analytics integration works with GA4 (Google Analytics 4) measurement IDs that start with `G-`.
</Info>

## Getting Your Measurement ID

1. Go to [Google Analytics](https://analytics.google.com/)
2. Select your property (or create one)
3. Go to **Admin** → **Data Streams**
4. Select your web stream (or create one)
5. Copy the **Measurement ID** (starts with `G-`)

## Adding GA4 to Your Docs

Add the measurement ID to your `docs.json`:

```json docs.json
{
  "name": "My Docs",
  "integrations": {
    "ga4": {
      "measurementId": "G-XXXXXXXXXX"
    }
  }
}
```

Replace `G-XXXXXXXXXX` with your actual measurement ID.

## Viewing Your Data

After adding the integration:

1. Trigger a rebuild of your docs
2. Visit your live documentation site
3. In Google Analytics, go to **Reports** → **Real-time**
4. You should see your visit appear within 30 seconds

<Note>
It can take 24-48 hours for data to appear in standard reports. Use Real-time reports for immediate verification.
</Note>

## Using with Google Tag Manager

If you're already using Google Tag Manager, you can configure GA4 through GTM instead of adding it directly. See [Google Tag Manager Integration](/integrations/google-tag-manager) for details.

<Warning>
Don't add the same GA4 property both directly in `docs.json` and through Google Tag Manager—this will cause duplicate tracking.
</Warning>

## Privacy Considerations

Google Analytics collects visitor data. Consider:

- Adding a cookie consent banner if required by GDPR/CCPA
- Updating your privacy policy to mention analytics
- Using [IP anonymization](https://support.google.com/analytics/answer/2763052) if needed

## Troubleshooting

<Accordion title="Not seeing any data">
  1. **Verify your measurement ID** - It must start with `G-`
  2. **Check for ad blockers** - They may block analytics scripts
  3. **Wait for rebuild** - Changes require a new build to take effect
  4. **Use Real-time reports** - Standard reports have a 24-48 hour delay
</Accordion>

<Accordion title="Seeing 'Invalid Measurement ID' error">
  The ID must:
  - Start with `G-`
  - Contain only letters and numbers after `G-`
  - Be copied exactly from Google Analytics (no extra spaces)
</Accordion>

## Related Articles

<Columns cols={3}>
  <Card title="Google Tag Manager" icon="tags" href="/integrations/google-tag-manager">
    Use GTM for advanced tag management
  </Card>
  <Card title="Plausible Analytics" icon="chart-pie" href="/integrations/plausible-analytics">
    Privacy-focused alternative to GA4
  </Card>
  <Card title="Project Analytics" icon="chart-line" href="/setup/project-analytics">
    View built-in Jamdesk analytics
  </Card>
</Columns>
