Google Analytics Integration
How to integrate Superline Agent Detection with Google Analytics
Integrating with Google Analytics
This guide will show you how to integrate Superline Agent Detection with Google Analytics 4 (GA4) to segment your data and metrics based on whether users are humans or AI agents.
Why Separate Human and AI Traffic
Analytics data is most valuable when it accurately reflects how humans interact with your site. With the growing prevalence of AI agents browsing the web, your analytics may be skewed by non-human traffic, leading to:
- Inaccurate conversion rates
- Misleading engagement metrics
- Skewed A/B test results
- Distorted user behavior analysis
By identifying and segmenting AI agent traffic using Superline Agent Detection, you can maintain clean analytics data that accurately represents human behavior.
Integration Steps
Install Superline Agent Detection
First, install the Superline Agent Detection library:
or use a script tag:
Initialize Both Libraries
Make sure both GA4 and Superline Agent Detection are initialized early in your application lifecycle:
Detect AI Agents and Send to GA4
After allowing sufficient time for data collection (typically a few seconds), check if the current session is from an AI agent and send this information to GA4:
Create Custom Dimensions in GA4
In your Google Analytics 4 property:
- Go to Admin > Custom definitions > Create custom dimensions
- Create two custom dimensions:
- Name: “Is Agent”, Scope: “User”, User property: “is_agent”
- Name: “Agent Confidence”, Scope: “User”, User property: “agent_confidence”
Create Segments for Analysis
Create segments to analyze human vs. AI traffic separately:
- Go to any report in GA4
- Click the ”+” button in the segments section
- Create two segments:
- Human Users: Add condition where “Is Agent” equals “false”
- AI Agents: Add condition where “Is Agent” equals “true”
Comprehensive Implementation Example
Here’s a complete example that handles various scenarios:
Advanced Analytics Options
Analyzing the Data
Once integrated, you can use GA4’s reporting tools to gain insights such as:
Conversion Rate Differences
Compare conversion rates between human users and AI agents to understand how bots might be skewing your metrics.
Navigation Patterns
Identify differences in page flow and navigation patterns between humans and AI agents.
Engagement Metrics
Compare session duration, pages per session, and bounce rates to understand how agent traffic differs from human traffic.
Feature Usage
Determine if AI agents interact with certain features of your site differently than humans.
Best Practices
- Delay Initial Collection: Allow at least 3-5 seconds of interaction before finalizing detection for better accuracy
- Review Confidence Distribution: Analyze the
agent_confidence
distribution in GA4 instead of relying solely onis_agent
- Review Regularly: Monitor the proportion of AI traffic over time to spot trends
- Create Comparative Reports: Set up reports that compare key metrics between human and AI segments
- Adjust Threshold Based on Needs: Depending on your tolerance for false positives vs. false negatives, adjust your reporting threshold based on the
agent_confidence
, or use thethreshold
init option.