The search landscape has fundamentally changed through Google’s AI Overviews, Featured Snippets, and "People also ask" results. As we know these AI-powered features appear prominently in search results and can drive traffic to websites. But how can you measure whether and how much traffic these features actually bring to your website?
The Problem: "Invisible" Traffic in GA4
Google Analytics 4 doesn’t show by default whether visitors came to your website via AI Overviews, Featured Snippets, or "People also ask" boxes. These traffic sources are simply classified as "Google / organic," causing valuable insights to be lost.
While we covered this earlier, there have been changes to GA4 in this regard, and our previous article is superseded by this on.
The Solution: URL Fragment Tracking
The key lies in the URL structure. When users click on links from AI Overviews or Featured Snippets, Google often appends a special URL fragment:
https://your-website.com/article#:~:text=Highlighted%20text%20from%20the%20snippet
The crucial element is #:~:text=, followed by the highlighted text. This fragment leads users directly to the relevant text section on your page.
Step-by-Step Guide
Now let’s get practical! We’ll guide you through the complete implementation of tracking. You’ll need Google Tag Manager and Google Analytics 4 for this. If you’re not already working with GTM, now is a good time to start – it’s worth it!
Step 1: Create JavaScript Variables in Google Tag Manager
First, you need two custom JavaScript variables in GTM to extract the snippet information from the URL.
Create Variable for Snippet Start
- Navigate to Variables in GTM
- Click New under User-Defined Variables
- Select Custom JavaScript as the variable type
- Insert the following code:
function() {
var snippetEntry = decodeURIComponent(performance.getEntries()[0].name.match("#:~:text=(.*)")[1]);
var fragment = snippetEntry.replace(/, /g,"*").replace(/,/g,"...").replace(/\*/g,", ");
var splitArray = fragment.split("...");
return splitArray[0];
}
- Name the variable "cJS - URL Snippet Start" and save it.

Create Variable for Snippet End
- Create another Custom JavaScript Variable.
- Insert the following code:
function() {
var snippetEntry = decodeURIComponent(performance.getEntries()[0].name.match("#:~:text=(.*)")[1]);
var fragment = snippetEntry.replace(/, /g,"*").replace(/,/g,"...").replace(/\*/g,", ");
var splitArray = fragment.split("...");
return splitArray[splitArray.length - 1];
}
- Name the variable "cJS - URL Snippet End" and save it.

Step 2: Send Data to GA4
You have two options to transfer the snippet data to GA4:
Option 1: Add Parameters to Existing Page View Event
If you already have a GTAG with page view in GTM:
- Edit your existing GTAG.
- Add two new parameters under "Event Parameters":
- Parameter 1:
- Event Parameter:
snippet_text_start - Value:
{{cJS - URL Snippet Start}}
- Event Parameter:
- Parameter 2:
- Event Parameter:
snippet_text_end - Value:
{{cJS - URL Snippet End}}
- Event Parameter:
- Parameter 1:

Option 2: Create New GA4 Event
For clean data separation, you can create a separate event:
- Create Trigger:
- Go to Triggers and click New.
- Select Page View as the trigger type.
- Under "This trigger fires on," select Some Page Views.
- Condition:
{{cJS - URL Snippet Start}}does not equalundefined.
- Name the trigger "Page View - URL Snippet Present".
- Note: Remember to adapt your consent settings for the new trigger.
- Create Tag:
- Go to Tags and click New.
- Select Google Analytics: GA4 Event.

- Event Name:
snippet_text

- Add both event parameters (as in Option 1).

- Link the previously created trigger.

Step 3: Create Custom Dimensions in GA4
To use the data in GA4 reports, you need custom dimensions:
- Go to Admin (gear icon bottom left) > Custom Definitions in GA4.
- Click Create Custom Dimension.
- First Dimension:
- Dimension name: Snippet Start
- Scope: Event
- Event parameter:
snippet_text_start
- Second Dimension:
- Dimension name: Snippet End
- Scope: Event
- Event parameter:
snippet_text_end
- Don't forget to save.

Data Analysis and Insights
Creating Reports
With the collected data, you can subsequently perform valuable analyses. A custom report can show you which pages receive the most snippet traffic and which snippet text generates the highest engagement rate. Particularly interesting is the question of whether visitors from AI Overviews or snippets convert better than regular organic traffic.
For content optimization, you gain insights about which text passages are most frequently highlighted in snippets. You can identify patterns in successful snippet texts and specifically optimize content for better snippet performance.
Creating Audiences
Create special audiences for snippet traffic to better understand the behavior of these valuable visitors. Depending on which implementation method you chose, you proceed differently:
If you chose Option 1 (added parameters to page_view event): Create an audience in GA4 for users who have a value in the dimensions "Snippet Start" or "Snippet End". Go to Admin > Audiences > New Audience and select as condition: Custom Dimension "Snippet Start" is not empty.
If you chose Option 2 (created separate event): Create an audience for users who triggered the snippet_text event. In the audience settings, select as condition: Event name exactly matches "snippet_text".
You can then use these audiences for remarketing campaigns or analyze their behavior compared to regular organic visitors.
Integration with Other Data Sources
Combine your GA4 data with other tools for further analysis. For example, you can blend your GA4 and Google Search Console data in Google Looker Studio.
Important Limitations
Incomplete Coverage
Important to know: Not every click from AI Overviews or Featured Snippets contains the URL fragment. The method therefore captures only a portion of the actual snippet traffic. Different SERP features also use the same URL pattern, making differentiation difficult.
Technical Limitations
The tracking works exclusively with URLs that have the specific fragment pattern. JavaScript must be enabled for the user, and some browsers or consent settings can impair tracking. You should consider these factors when interpreting your data.
Best Practices for Implementation
Testing and Validation
Test thoroughly before going live. Use the preview mode in Google Tag Manager to test the implementation and check in the real-time reports whether events are arriving correctly in GA4. Monitor data quality and ensure that snippet texts are captured correctly.
Monitoring and Maintenance
Regularly monitor data quality and update the tracking codes in GTM if Google changes anything in its implementation. Document all changes for your team so everyone can understand how the tracking works.
Consider Data Privacy
Ensure that tracking complies with GDPR requirements. Inform your users about the extended tracking and implement appropriate opt-out mechanisms.
Conclusion: More Transparency for Your SEO Performance
Tracking AI Overview and Featured Snippet traffic provides valuable insights into your SEO strategy performance. Even though the method doesn’t capture every click, it delivers important data for your content optimization to understand which content performs in snippets.
You can identify successful snippet optimizations, evaluate the ROI of Featured Snippet optimizations, and analyze the behavior of "snippet visitors." The implementation requires technical know-how, but the gained insights justify the effort.
In a time when AI-powered search results are becoming increasingly important, this tracking gives you a decisive advantage in optimizing your SEO performance.
Tip: Start with a test phase on selected pages before implementing tracking site-wide. This way you can validate data quality and adjust the setup if needed.


