How To Track AI Traffic In GA4 Without Undercounting It

How To Track AI Traffic In GA4 Without Undercounting It

The rise of artificial intelligence has fundamentally changed how users find information online. Instead of relying solely on traditional search engines, millions of users now turn to AI assistants and generative search engines like ChatGPT, Claude, Perplexity, and Google Gemini to answer their queries. For digital marketers, SEOs, and content creators, this shift has introduced a brand-new source of highly valuable referral traffic.

To help businesses measure this new source of traffic, Google Analytics 4 (GA4) introduced a default channel grouping specifically for AI assistants. However, relying purely on GA4’s default settings means your AI referral numbers are likely quietly, and significantly, wrong. Due to the way GA4 categorizes incoming traffic, your actual AI search traffic is being fragmented across three separate channels, resulting in a severe undercount.

Understanding why this fragmentation happens and learning how to build a robust tracking solution is essential to accurately measure your generative engine optimization (GEO) efforts. Below, we examine the flaws in GA4’s default AI traffic tracking and provide a step-by-step guide to fixing them.

The Problem with GA4’s Default AI Assistant Channel

Google Analytics 4 uses a system called Default Channel Grouping (DCG) to automatically bucket incoming traffic into broad categories like “Organic Search,” “Direct,” “Referral,” and “Organic Social.” Recently, Google added the “AI Assistant” channel to this mix, designed to automatically capture traffic originating from conversational AI tools.

While this was a welcome addition, the default implementation falls short in practice. Instead of collecting all AI-driven visits into this single dedicated bucket, GA4 frequently fragments traffic from a single AI source into three distinct channels:

  • The “AI Assistant” Channel: This channel only captures traffic that matches Google’s rigid, predefined list of recognized AI referrers.
  • The “Referral” Channel: If an AI platform uses a new domain, a lesser-known subdomain, or an unrecognized referrer path, GA4 fails to recognize it as an AI assistant and dumps it into the standard Referral channel.
  • The “Direct” Channel: This is the most significant leak. When users access AI assistants through native mobile apps (such as the ChatGPT or Claude iOS and Android apps) or desktop applications, the referrer data is often stripped entirely. Because no referrer header is sent, GA4 categorizes these highly engaged visits as “Direct” traffic.

This fragmentation creates a major blind spot. If your reporting shows a flat or declining trend in AI assistant traffic, it may not be because users aren’t clicking your links; instead, those visits may simply be hidden within your standard referral and direct traffic metrics.

Why Accurate AI Attribution Matters for Modern SEO

As search engines evolve into answer engines, optimization strategies must adapt. Generative Engine Optimization (GEO) and AI Search Optimization (AIO) require dedicated tracking to prove their business value. If you cannot accurately measure the traffic coming from these platforms, you face several distinct disadvantages.

Proving the ROI of AI Optimization

Securing budget and resources for new marketing initiatives requires clear proof of concept. If your content is being cited in ChatGPT’s SearchGPT or Perplexity, but those clicks are mislabeled as direct traffic, you cannot demonstrate the true return on investment for your optimization efforts.

Informing Content Strategy

AI assistants tend to refer users who are further along in the buying journey, as they have already interacted with an AI to refine their search. Knowing which specific AI platforms drive the most engaged traffic to your site allows you to tailor your content format, tone, and structured data to better appeal to those specific LLM (Large Language Model) crawlers.

Accurate Stakeholder Reporting

Reporting inaccurate data to clients or internal stakeholders damages credibility. Relying on default GA4 reports means presenting undercounted metrics that do not reflect the reality of how users are interacting with your brand online.

How AI Traffic Gets Fragmented: A Closer Look

To solve the tracking issue, we must first understand how different AI platforms send referral data. The fragmentation of AI traffic is primarily driven by three technical factors: referrer headers, browser security protocols, and app-to-web transitions.

1. Changing and Evolving Domains

AI startups move quickly, which often results in domain migrations and the creation of various subdomains. For example, OpenAI initially served ChatGPT from chat.openai.com, but has since transitioned primary user traffic to chatgpt.com. If a web analytics platform’s default regex patterns do not update in real-time to match these transitions, traffic from the newer domains temporarily spills into the standard “Referral” bucket.

2. Mobile and Desktop App Transitions

A huge portion of conversational AI usage occurs within dedicated mobile apps on iOS and Android. When a user clicks a link inside a native mobile app to open a web page in their system browser, the referral handshake is frequently broken. Without a clean referrer header (like https://chatgpt.com), GA4 has no way of knowing where the user came from, leaving it with no choice but to label the traffic as “Direct.”

3. Security and Privacy Protocols

Many privacy-focused AI search engines or browsers strip referrer data to protect user privacy. In other cases, secure HTTPS platforms linking to non-secure HTTP websites will automatically drop the referrer header entirely. While HTTP to HTTPS transitions are less common today, standard security policies on modern web servers can still limit the amount of referrer data passed to your website.

Step-by-Step Guide to Creating a Custom AI Traffic Channel in GA4

The most effective way to prevent your AI referral numbers from being undercounted is to build a Custom Channel Group in GA4. This allows you to override Google’s default categorizations and group all AI-related traffic into one clean, consolidated bucket.

Step 1: Identify Your Existing AI Traffic Sources

Before building your custom channel, you need to find out where your AI traffic is currently hiding. Run a detailed examination of your existing traffic data:

  1. Navigate to Reports > Acquisition > Traffic acquisition in your GA4 property.
  2. Set the primary dimension to Session source/medium.
  3. Use the search bar to filter for known AI terms, such as “chat”, “ai”, “openai”, “perplexity”, “claude”, or “gemini”.
  4. Note down any instances where these sources are categorized outside the default “AI Assistant” channel (e.g., if chatgpt.com / referral is sitting in the standard Referral channel).

Step 2: Access the Channel Groups Settings

To create a custom channel grouping, you must have Administrator or Editor access to your GA4 property.

  1. Click on the Admin gear icon in the bottom-left corner of the GA4 interface.
  2. Under the Data display menu, click on Channel groups.
  3. You will see the “Default Channel Group.” Rather than editing this directly, it is best practice to click Create new channel group. This ensures you preserve the original default data structure for comparison.
  4. Give your new group a descriptive name, such as “Custom Channel Grouping.”

Step 3: Define Your Consolidated “AI Traffic” Channel

Within your new custom channel group, you will define the rules that dictate how traffic is assigned. We want to build a rule that captures all variations of AI traffic and aggregates them before they can be categorized as standard referrals.

  1. Click on Add new channel.
  2. Name the channel Consolidated AI Traffic.
  3. Under the channel rules, set the condition to match your identified AI referrers. The most reliable way to do this is by using the Source dimension with a regular expression (regex).
  4. Select Source as your dimension, set the match type to matches regex, and input a comprehensive regex pattern that targets known AI engines.

Here is an example of a robust regex pattern designed to capture major AI traffic sources:

.*(openai|chatgpt|perplexity|claude|anthropic|gemini|copilot|bard|mistral|phind|character.ai).*

This pattern ensures that any session source containing these specific brand names will be funneled directly into your new “Consolidated AI Traffic” channel, regardless of whether they are formatted as subdomains or alternative top-level domains.

Step 4: Order Your Channel Rules Correctly

GA4 evaluates channel rules sequentially, from top to bottom. Once a session matches a rule, it is assigned to that channel and no further rules are evaluated.

Because of this, you must position your new Consolidated AI Traffic rule high up in the evaluation order—specifically, above the standard “Referral” and “Organic Search” rules. If your custom AI rule sits below the general “Referral” rule, GA4 will continue to classify your AI traffic as standard referrals before it ever reaches your custom filter.

  1. In your Custom Channel Group configuration screen, look at the list of channels.
  2. Drag your newly created Consolidated AI Traffic channel to the top of the list, or at least above the “Referral” and “Direct” options.
  3. Click Save group.

How to Capture Missing App Traffic with Google Tag Manager

While Custom Channel Grouping fixes the issue of AI traffic being miscategorized as standard “Referrals,” it cannot automatically fix the “Direct” traffic leak caused by mobile apps stripping referrer data. To solve this, we must use Google Tag Manager (GTM) to inspect and rewrite traffic data before it is sent to GA4.

Many native AI apps pass a custom user-agent string or use a specific system-level referral path when opening in-app browsers. For example, the ChatGPT Android app often passes a referrer of android-app://com.openai.chatgpt. While GA4’s default processing struggle to read this cleanly, we can intercept it with GTM.

Creating a Referrer Variable in GTM

To capture this hidden data, we can create a user-defined variable in GTM that looks specifically for app-based referrers:

  1. Log into your Google Tag Manager container.
  2. Navigate to Variables and click New under User-Defined Variables.
  3. Select Referrer as the Variable Type.
  4. Set the Component Type to Full URL.
  5. Name the variable dl_referrer.

Setting Up a Regex Table to Overwrite Source and Medium

Next, we will use a Regex Table to translate messy app referrers into clean source and medium values that GA4 can understand.

  1. Create a second User-Defined Variable and select Regex Table as the type.
  2. Set the Input Variable to the dl_referrer variable you created in the previous step.
  3. Add rows to map app referrers to clean names. For example:
    • Pattern: ^android-app://com.openai.chatgpt.*Output: chatgpt-app
    • Pattern: ^android-app://com.perplexity.*Output: perplexity-app
  4. Set a default value to return {{Referrer}} if no matches are found, ensuring you do not overwrite standard web referrers.
  5. Name this variable cleaned_ai_source.

Updating Your GA4 Configuration Tag

Finally, you need to pass these cleaned values to GA4:

  1. Go to your GA4 Google Tag configuration in GTM.
  2. Under Configuration Parameter, add a parameter named page_referrer.
  3. Set its value to your newly created {{cleaned_ai_source}} variable.
  4. Save your changes and publish the GTM container.

By capturing the app-specific referrers and passing them explicitly to GA4, you prevent mobile app clicks from falling into the “Direct” traffic black hole.

Verifying and Testing Your New AI Tracking Setup

Once you have implemented your custom channel groups and GTM tags, it is vital to test the implementation to ensure your data is flowing correctly.

Using the GA4 Realtime Report

To verify that GTM is actively passing the corrected referrers, navigate to Reports > Realtime in GA4. Trigger a test visit using an AI tool if possible, or look at the active users’ source and medium parameters. If your GTM setup is working, you should begin to see sources like chatgpt-app appear in real-time, rather than being classified as “direct.”

Testing Custom Channel Grouping Retroactively

It is important to note that Custom Channel Groupings in GA4 are applied retroactively to your historical data within reports. This is a massive advantage, as it allows you to instantly see how much of your past traffic was being miscategorized.

To see your new grouping in action, build a custom Exploration Report:

  1. Go to the Explore tab in GA4 and create a blank exploration.
  2. Import the dimension Custom Channel Grouping (using the specific name you gave your new group) and Sessions.
  3. Drag your custom channel dimension into the rows and Sessions into the values.
  4. Compare the session counts in your “Consolidated AI Traffic” channel against the default “AI Assistant” channel to see exactly how much traffic you were previously undercounting.

Maintaining Your AI Tracking in the Future

The AI space is incredibly dynamic. New tools, engines, and platforms emerge constantly, and existing platforms frequently update their infrastructures. To keep your tracking accurate over time, implement the following best practices:

  • Perform Monthly Audits: Set a recurring reminder to check your standard “Referral” and “Unassigned” traffic buckets. Look for new, unrecognized domains containing “ai”, “chat”, or “bot” and add them to your Custom Channel Group regex.
  • Monitor Industry Announcements: Major releases, such as the full rollout of Apple Intelligence or new search features from Anthropic, are likely to introduce new referrer formats. Keep your GTM regex tables updated to accommodate these new platforms.
  • Keep Your Teams Aligned: Ensure that your SEO, development, and analytics teams are aware of these custom groupings so that any updates to the website’s technical architecture or tag management do not accidentally overwrite these tracking parameters.

Conclusion

As conversational platforms continue to secure their place in the search landscape, tracking how these tools drive traffic to your website is no longer optional. Relying on GA4’s default setup leaves you vulnerable to fragmented, incomplete data that undercounts your actual audience reach.

By taking control of your analytics with Custom Channel Groupings and leveraging Google Tag Manager to capture elusive app-to-web visits, you can eliminate the blind spots. Accurate tracking provides the clean, reliable data you need to optimize your content strategy, demonstrate true marketing ROI, and successfully navigate the era of AI-driven search.

Leave a Comment

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

Scroll to Top