Documentation

Connect Google Analytics

This page allows you to connect Spyglasses to your Google Analytics. Once connected, Spyglasses forwards all AI visits (specifically AI Assistant traffic, not other bot types) to your Google Analytics as page_view events using the Measurement Protocol.

What You'll Learn

In this guide, you'll learn:

  • How to connect Google Analytics
  • What data is sent to GA4
  • Important limitations to understand
  • How to verify the integration works

Prerequisites

This dashboard requires the Spyglasses AI Traffic Analytics plugin to be installed on your website. Without the plugin, there's no AI traffic to forward.

What You'll Need

To connect Google Analytics, you need two things from your GA4 property:

1. Measurement ID

This is your GA4 property identifier. It starts with G- (e.g., G-XXXXXXXXXX).

To find it:

  1. Log into Google Analytics
  2. Go to Admin (gear icon)
  3. Select your property
  4. Click "Data Streams"
  5. Select your web stream
  6. Copy the Measurement ID

2. API Secret

This is a secret key that authorizes Measurement Protocol requests.

For detailed instructions on generating an API secret, see How to Get Your GA4 API Secret.

Quick steps:

  1. In your GA4 web stream settings
  2. Scroll to "Measurement Protocol API secrets"
  3. Click "Create"
  4. Give it a name (e.g., "Spyglasses")
  5. Copy the generated secret value

Connecting the Integration

  1. Enter your Measurement ID (G-XXXXXXXXXX)
  2. Enter your API Secret
  3. Click "Save" or "Connect"
  4. Spyglasses will verify the connection

Once connected, AI visit data starts flowing to your Google Analytics within minutes.

What Data is Sent

Spyglasses sends page_view events for AI Assistant visits with:

  • Page URL
  • Page title
  • AI platform identifier (ChatGPT, Claude, etc.)
  • Timestamp
  • Geographic information (if available)

Note: Only AI Assistant traffic is forwarded—not AI Model Training crawlers, search engine crawlers, or other bot types. This keeps your GA4 data focused on meaningful AI visibility data.

Important Limitations

Session ID Requirement

Many reports and views in Google Analytics require the presence of a session ID (session_id), which cannot be generated when we send traffic over Measurement Protocol.

Google requires session IDs to be generated by human visits logged through their JavaScript snippet. Server-side events via Measurement Protocol don't have access to the client-side session context.

What this means:

  • AI visit data will appear in some GA4 reports but not all
  • Session-based reports may not show Spyglasses data
  • Some standard reports filter out events without sessions

Creating Custom Reports

To see your AI traffic data in GA4, you may need to create custom reports or audiences that don't depend on session ID.

For step-by-step instructions, see Creating a GA4 Custom Audience for AI Traffic.

Affected Reports

Reports that typically work:

  • Events report (showing page_view events)
  • Realtime overview (with limitations)
  • Custom explorations filtering by event parameters

Reports that may not show Spyglasses data:

  • Acquisition reports (may require sessions)
  • Engagement reports
  • User journey reports
  • Attribution reports

Verifying the Connection

After connecting, verify data is flowing:

In Spyglasses

Check that the integration shows "Connected" status and displays recent sync activity.

In Google Analytics

  1. Go to Reports > Realtime
  2. Look for page_view events
  3. Filter by event parameter for AI source

Or:

  1. Go to Explore
  2. Create a new exploration
  3. Add page_view as your event
  4. Filter to events with AI-related parameters
  5. Verify data appears

Troubleshooting

If data isn't appearing:

  1. Check credentials: Verify Measurement ID and API Secret are correct
  2. Wait 24 hours: GA4 can have processing delays
  3. Check property settings: Ensure your GA4 property accepts Measurement Protocol data
  4. Verify AI traffic exists: Check Spyglasses AI Traffic Analytics dashboard for data

Disconnecting

To disconnect the integration:

  1. Click "Disconnect" or "Remove"
  2. Confirm the action
  3. Spyglasses stops sending data immediately

Historical data already in GA4 remains; this only stops future data flow.

Best Practices

Use a Dedicated API Secret

Create an API secret specifically for Spyglasses rather than reusing one from other integrations. This makes it easier to revoke access if needed.

Create Custom Dimensions

For better analysis in GA4, consider creating custom dimensions to track:

  • AI platform (ChatGPT, Claude, etc.)
  • Visit type (citation vs. click-through)
  • Page intent

Combine with GA4 Native Data

Use Spyglasses data alongside your regular GA4 tracking to:

  • Compare AI-referred traffic to organic traffic
  • Track conversion rates by traffic source
  • Build unified reporting

Monitor Data Quality

Periodically verify:

  • Data is still flowing
  • Event counts match between Spyglasses and GA4
  • No unexpected gaps in data