The DIY Guide: How to Track AI Traffic in Google Analytics 4

Back to Home

The DIY Guide: How to Track AI Traffic in Google Analytics 4

Create a custom 'AI Search' channel in GA4 to track LLM referral traffic

Can Google Analytics 4 track ChatGPT traffic?

Yes, but it requires manual configuration to be accurate. By default, GA4 often lumps AI traffic into generic "Referral" or "Direct" buckets. To see it clearly, you must create a custom "AI Search" channel group using a specific Regex formula to catch the referral sources.

Step 1: The "AI Search" Regex Formula

Copy this code. It captures the referral strings for all major AI engines (ChatGPT, Gemini, Claude, Perplexity, Copilot, and Bing Chat):

.*chatgpt.*|.*openai.*|.*perplexity.*|.*gemini.*|.*claude.*|.*copilot.*|.*bing.*|.*bard.*

Step 2: How to Create an "AI Search" Channel in GA4

Follow these steps to make "AI Search" a permanent row in your reporting:

  1. Open Admin: Click the Gear Icon (Admin) in the bottom left of GA4.
  2. Navigate: Under Data Display, select Channel Groups.
  3. Create: Click Create new channel group (or duplicate the Default group).
  4. Name It: Enter "AI Search" as the name.
  5. Define Rule:
    • Set the Parameter to Session source
    • Set the Operator to matches regex
    • Paste the formula from Step 1 into the Value field
  6. Prioritize: Drag your new "AI Search" channel to the top of the list.

    Why? GA4 processes rules in order. If "Referral" is above "AI Search," GA4 will catch the traffic as "Referral" first and stop looking.

  7. Save: Click Save.

Step 3: What are the limitations?

This DIY method only captures traffic where the Referrer Header is intact. There are important limitations to understand:

The "Dark Social" Problem

If a user clicks a link from inside a mobile app (like the ChatGPT iOS app), the referral data is often stripped, meaning that traffic will still appear as "Direct". To solve this "Dark Social" issue and track bot-level data, you would need a server-side tool like Profound Agent Analytics.

What GA4 Cannot Track:

  • Bot visits: When AI crawlers read your content without a user click
  • Mobile app referrals: Traffic from ChatGPT, Claude, or Perplexity mobile apps
  • Embedded AI: When AI answers are shown in other apps that strip referrer data
  • Training vs. RAG: Whether bots are indexing for training or fetching for live answers

What GA4 Can Track:

  • Web referrals: Users clicking links from AI web interfaces (chat.openai.com, perplexity.ai, etc.)
  • Desktop traffic: Most desktop browser clicks preserve referrer data
  • Trends over time: Even partial data shows directional trends in AI traffic

Need More Complete AI Tracking?

For server-side tracking that captures 100% of AI bot traffic, explore dedicated AI analytics tools.

Frequently Asked Questions

Will this regex catch all AI traffic?

No, this regex catches the major known AI referral sources. New AI tools may emerge with different referral strings. You should periodically review your 'Referral' channel for new AI-related sources and update the regex accordingly.

Why is my AI traffic still showing as 'Direct'?

Mobile app traffic (ChatGPT iOS/Android, Claude app, etc.) often strips referrer headers for privacy. This traffic will appear as 'Direct' in GA4 regardless of your channel configuration. Server-side analytics tools can help attribute this traffic.

Can I use this same regex in other analytics tools?

Yes, this regex pattern works in most analytics platforms that support regex matching, including Adobe Analytics, Mixpanel, and Amplitude. The exact configuration steps will differ by platform.