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:
- Log into Google Analytics
- Go to Admin (gear icon)
- Select your property
- Click "Data Streams"
- Select your web stream
- 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:
- In your GA4 web stream settings
- Scroll to "Measurement Protocol API secrets"
- Click "Create"
- Give it a name (e.g., "Spyglasses")
- Copy the generated secret value
Connecting the Integration
- Enter your Measurement ID (G-XXXXXXXXXX)
- Enter your API Secret
- Click "Save" or "Connect"
- 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
- Go to Reports > Realtime
- Look for page_view events
- Filter by event parameter for AI source
Or:
- Go to Explore
- Create a new exploration
- Add
page_viewas your event - Filter to events with AI-related parameters
- Verify data appears
Troubleshooting
If data isn't appearing:
- Check credentials: Verify Measurement ID and API Secret are correct
- Wait 24 hours: GA4 can have processing delays
- Check property settings: Ensure your GA4 property accepts Measurement Protocol data
- Verify AI traffic exists: Check Spyglasses AI Traffic Analytics dashboard for data
Disconnecting
To disconnect the integration:
- Click "Disconnect" or "Remove"
- Confirm the action
- 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
Related
- Getting Started - Install the tracking plugin
- GA4 API Secret Guide - Detailed setup instructions
- GA4 Custom Audience for AI Traffic - Create reports that work with this data
- AI Traffic Analytics - View AI traffic in Spyglasses