Banner image with the text "Detect AI Overview Traffic in GA4" and scientific-style icons in the background

How to Track Google’s AI Overview Traffic in GA4 Using URL Fragments

Ever since Google rolled out AI Overviews in the Netherlands, many websites have noticed a drop in organic traffic. That’s no coincidence. With AI-generated summaries answering questions right on the results page, fewer people are clicking through to actual websites.

But here’s the good news: if users do click through, there’s still a way to detect that traffic — even though GA4 currently groups it under regular google / organic.

So… can you track AI Overview clicks?

Not directly. Google doesn’t label this traffic differently in Analytics. But there’s a clever workaround based on how Google links to content from an AI Overview.

When Google pulls a quote or text snippet from your page, it appends something called a URL fragment to the link — more specifically: #:~:text=...

That fragment sends the user directly to a highlighted piece of your content. And that behavior gives us a way to detect when traffic likely came from an AI Overview.

Step-by-step: how to flag AI Overview traffic in GTM

1. Create a Custom JavaScript Variable

  1. In Google Tag Manager, go to Variables
  2. Click New → Variable Type: Custom JavaScript
  3. Name it something like: AI Overview Trigger (URL Fragment)
  4. Paste the following code:

function() {
  var hasFragment = location.href.includes('#:~:text=');
  var isFromGoogle = document.referrer.includes('google.');
  return hasFragment && isFromGoogle;
}

Screenshot of Google Tag Manager showing a custom JavaScript variable to detect AI Overview traffic via URL fragment

 

This variable checks:

  • Whether the page URL contains a #:~:text= fragment
  • Whether the referrer includes “google.” (e.g. google.com, google.nl)

2. Create a GA4 Event Tag

Now that your variable detects AI Overview visits, you can send that signal to GA4 via a custom event tag:

  1. Go to Tags in GTM
  2. Create a new tag: Google Analytics: GA4 Event
  3. Select your existing GA4 Configuration Tag
  4. Use this for event name: ai_overview_click
  5. Optional: Add event parameters like:

traffic_source : ai_overview

3. Set Up the Trigger

  1. Click Triggering → New
  2. Select Page View (or Custom Event)
  3. Set condition:
    AI Overview Trigger (URL Fragment) equals true

Save your tag. You now have a functioning event that will fire only when someone lands on your site via an AI Overview link.

Why this matters

Knowing when your site is being referenced in AI Overviews can help you:

  • Measure how often Google includes your content in summaries
  • Evaluate whether those appearances actually bring in traffic
  • Adapt your SEO and content strategy accordingly

Heads-up: Limitations

  • This method relies on the current way Google links to content. If Google changes the format, this technique may need updating.
  • This only works for sessions where the user actually clicks through — you can’t track impressions.
  • Referrer values may be stripped or blocked by browser settings in some cases.

Final thoughts

AI Overviews are here to stay, and they’re already reshaping how people search — and how often they click. But that doesn’t mean you’re in the dark. With a little creativity in GTM, you can start measuring this traffic and take back some visibility.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top