← Back to insights
Guide · #721

GA4 for AEO: The Custom Dimensions to Add

Track AI referral traffic in GA4. Custom dimensions for AEO: source, model, query, intent. Step-by-step setup guide for founders optimizing for ChatGPT and Perplexity.

Filed
May 8, 2026
Read
16 min
Author
The Seoable Team

Why Your GA4 Setup Is Missing AI Traffic

You shipped. You're getting organic traffic. But your GA4 dashboard doesn't tell you where it's coming from—especially from AI engines like ChatGPT, Perplexity, and Claude.

Default GA4 treats all referral traffic the same. It lumps AI citations together with Reddit spam and forum links. You can't see which AI model sent the visitor, what query they asked, or whether they came from a direct citation or a search result.

This is a problem. AI Engine Optimization (AEO) is not SEO. The metrics are different. The behavior is different. The conversion path is different.

If you're shipping content to get cited by AI, you need to measure it. That means custom dimensions in GA4.

This guide walks you through the exact custom dimensions to add, why they matter, and how to set them up in under 30 minutes.

Prerequisites: What You Need Before Starting

Before you add custom dimensions, confirm you have the basics in place:

If you have all of these, you're ready to build AEO tracking.

The Five Custom Dimensions You Need for AEO

Not all custom dimensions matter. Most GA4 implementations are bloated with dimensions that nobody reads.

For AEO, you need five. These five tell you everything you need to know about AI referral traffic:

1. AI Source (Which Engine Sent Them)

This dimension answers: Did this visitor come from ChatGPT, Perplexity, Claude, or another AI engine?

Default GA4 referral data doesn't distinguish between AI engines. They all show up as direct traffic or a generic referral domain.

You need to capture the actual AI source. This tells you which engines are citing you and which ones aren't.

Dimension name: ai_source Scope: User (captures at the session level) Parameter name: ai_source Data type: Text

2. AI Model (Which Version Cited You)

ChatGPT has multiple versions: GPT-4, GPT-4o, GPT-4 Turbo, GPT-3.5. Perplexity has Pro and free. Claude has multiple versions.

Different models have different citation behavior. GPT-4o might cite you more than GPT-3.5. Perplexity Pro users might convert better than free users.

Capturing the model tells you which versions of AI engines trust your content most.

Dimension name: ai_model Scope: Event (captures per interaction) Parameter name: ai_model Data type: Text

3. AI Query (What Did They Ask)

This is the actual question the user asked the AI engine before it cited your content.

Default GA4 doesn't capture this. You get a referral from Perplexity, but you don't know what query prompted the citation.

With this dimension, you can see patterns. Maybe your content ranks for "how to implement AEO" in ChatGPT but not for "best AEO tools." This tells you what your content actually solves for AI.

Dimension name: ai_query Scope: Event Parameter name: ai_query Data type: Text

4. Citation Type (Direct Citation or Search Result)

AI engines cite content in two ways:

  1. Direct citation. "According to [source], ..."
  2. Search result. The AI found your content in its search index and used it.

Direct citations are higher intent. They mean the AI engine specifically chose your content to answer the question.

Search results are lower intent. The AI engine found your content but may not have prioritized it.

This dimension tells you which type of citation you're getting.

Dimension name: citation_type Scope: Event Parameter name: citation_type Data type: Text Allowed values: direct or search_result

5. AI Intent (What Type of Answer Did It Need)

AI engines serve different types of queries:

  • Informational: "What is AEO?"
  • Comparative: "AEO vs. SEO: differences"
  • How-to: "How to optimize for AI"
  • Product recommendation: "Best AEO tools"
  • Opinion/analysis: "Is AEO worth it?"

Your content might rank for informational queries but not comparative ones. Or vice versa.

This dimension tells you what type of intent your content satisfies in AI engines.

Dimension name: ai_intent Scope: Event Parameter name: ai_intent Data type: Text Allowed values: informational, comparative, how_to, product_rec, opinion

Step 1: Register Custom Dimensions in GA4 Admin

Custom dimensions don't work until you register them in GA4. This is a one-time setup.

Step-by-step:

  1. Log into your GA4 property.
  2. Click Admin (bottom left).
  3. Under Data Collection and Modification, click Custom Definitions.
  4. Click Create Custom Dimension.
  5. Fill in the dimension details:
    • Dimension name: ai_source (or the dimension you're creating)
    • Description: "Which AI engine sent this visitor (ChatGPT, Perplexity, Claude, etc.)"
    • Scope: Choose User for ai_source, Event for all others
    • Event parameter: Match the parameter name you'll send from GTM (e.g., ai_source)
  6. Click Save.
  7. Repeat for all five dimensions.

Pro Tip: GA4 allows up to 25 custom dimensions on the free tier. You're using 5. You have 20 left for other tracking needs. Don't waste them on dimensions you won't use.

Once registered, dimensions take 24-48 hours to start collecting data. You won't see them in reports immediately.

Step 2: Set Up GTM Tags to Capture AI Source

Now that dimensions are registered, you need to send data to them. Google Tag Manager is the cleanest way to do this.

You'll create custom event tags that fire when a visitor arrives from an AI engine and pass the dimension data to GA4.

Creating a Custom Event for AI Source

In Google Tag Manager:

  1. Go to TagsNew.
  2. Name it: GA4 - AI Source Event.
  3. Choose tag type: Google Analytics: GA4 Event.
  4. Set Measurement ID to your GA4 property ID.
  5. Set Event Name to: ai_referral
  6. Under Event Parameters, add:
    • Parameter name: ai_source
    • Value: Use a variable to detect the referrer (see below)
  7. Click Save.

Creating a Variable to Detect AI Source

You need a variable that checks the referrer and identifies AI engines. GTM has a built-in Referrer variable, but you need a custom variable to parse it.

Create a Custom JavaScript Variable:

  1. Go to VariablesUser-Defined VariablesNew.
  2. Name it: AI Source Detector.
  3. Choose type: Custom JavaScript.
  4. Paste this code:
function() {
  var referrer = document.referrer.toLowerCase();
  
  if (referrer.includes('openai.com') || referrer.includes('chat.openai')) {
    return 'ChatGPT';
  } else if (referrer.includes('perplexity.ai')) {
    return 'Perplexity';
  } else if (referrer.includes('claude.ai') || referrer.includes('anthropic')) {
    return 'Claude';
  } else if (referrer.includes('google.com') && referrer.includes('ai')) {
    return 'Google AI Overview';
  } else if (referrer.includes('bing') && referrer.includes('copilot')) {
    return 'Copilot';
  } else if (referrer.includes('you.com')) {
    return 'You.com';
  } else {
    return 'Other';
  }
}
  1. Click Save.

Now update your GTM tag to use this variable:

  1. Go back to your GA4 - AI Source Event tag.
  2. In Event Parameters, set the Value for ai_source to your AI Source Detector variable.
  3. Save and Publish the container.

Warning: This method only works if the AI engine sends a referrer header. Some AI engines (like ChatGPT's mobile app) don't send referrer data. You'll miss some traffic. This is a limitation of browser-level tracking, not GA4.

Step 3: Capture AI Query and Model Data

AI source is good, but it's not enough. You also need to know what query prompted the citation and which model was used.

Here's the problem: AI engines don't pass query or model data in the referrer header. You can't detect it from the browser alone.

You have two options:

Option A: Manual URL Parameter (Easiest for Testing)

If you're testing or have control over how your content is shared, add URL parameters that capture query and model data.

For example, if Perplexity cites your content, the URL might look like:

https://yoursite.com/article?ai_source=perplexity&ai_model=pro&ai_query=how+to+implement+aeo

GTM can read these parameters automatically using the URL variable.

Create variables for each parameter:

  1. Go to VariablesNew.
  2. Choose type: URL Variable.
  3. Set Component Type to Query.
  4. Set Query Key to ai_query.
  5. Save.
  6. Repeat for ai_model.

Then in your GA4 event tag, map these variables to event parameters:

ai_query: {{Query - ai_query}}
ai_model: {{Query - ai_model}}

This works if you can control the URL or if you're tracking internal links. It doesn't work for external AI citations.

Option B: Server-Side Tracking (Most Accurate)

For real AI citations (where you can't control the URL), you need server-side tracking.

This is more complex, but it's the only way to capture query and model data from actual AI engine citations.

High-level approach:

  1. Set up a server-side GTM container on your domain (e.g., /gtm).
  2. Create a webhook or API endpoint that receives AI citation data.
  3. When an AI engine cites your content, it pings your webhook with query, model, and source data.
  4. Your server-side GTM container receives this data and sends it to GA4.

This requires backend work. If you're a technical founder, the GA4 documentation on server-side tracking is the starting point.

If you're not technical, stick with Option A for now. It's enough to start tracking AI traffic patterns.

Step 4: Add Citation Type Tracking

Citation type tells you whether your content was directly cited or found in a search result.

This is harder to detect automatically because it requires parsing the referrer URL or analyzing the click pattern.

Simple approach using UTM parameters:

When you share your content with AI tools or communities, add a UTM parameter:

https://yoursite.com/article?utm_source=ai&utm_medium=direct_citation&utm_campaign=chatgpt

GTM reads UTM parameters automatically. You can create a custom dimension that maps utm_medium to citation_type:

if utm_medium == 'direct_citation' → citation_type = 'direct'
if utm_medium == 'search_result' → citation_type = 'search_result'

Advanced approach:

If you're using server-side tracking, your webhook can include a citation_type parameter. The AI engine or your own system determines whether it's a direct citation or search result and passes that data to GA4.

Step 5: Set Up AI Intent Tracking

AI intent (informational, comparative, how-to, etc.) is best captured manually or through your content management system.

When you publish an article, tag it with its primary intent. Then, when someone lands on that page, GTM reads the intent tag and sends it to GA4.

Simple implementation:

  1. Add a data attribute to your page:

    <html data-ai-intent="how_to">
    
  2. In GTM, create a DOM Element variable that reads this attribute:

    • Variable name: Page AI Intent
    • Selection method: CSS Selector
    • CSS Selector: html
    • Attribute name: data-ai-intent
  3. In your GA4 event tag, add:

    ai_intent: {{Page AI Intent}}
    

Now every page view includes the intent dimension.

Pro Tip: If you're using a CMS like WordPress, use a plugin or custom field to add the data-ai-intent attribute. You don't need to edit HTML manually.

Step 6: Test Your Setup with Tag Assistant

Before you publish, verify that your tags are firing correctly and data is flowing to GA4.

Google Tag Assistant is built for this. Use the Tag Assistant to verify your tracking setup before going live.

Quick test:

  1. Install the Google Tag Assistant extension.
  2. Visit your site.
  3. Open Tag Assistant.
  4. Check that your GA4 tag fired.
  5. Click the GA4 tag to see the event parameters.
  6. Verify that ai_source, ai_query, ai_model, etc. are present and have correct values.

If parameters are missing or have wrong values, go back to GTM and fix the variable mappings.

Step 7: Access Custom Dimensions in GA4 Reports

Once data is flowing (after 24-48 hours), you can use custom dimensions in GA4 reports.

In standard reports:

  1. Go to any GA4 report (e.g., AcquisitionUser Acquisition).
  2. Click Rows (or the dimension selector).
  3. Search for your custom dimension (e.g., ai_source).
  4. Add it to the report.

Now you see traffic broken down by AI source, model, query, etc.

In Explorations (Advanced):

For deeper analysis, use GA4 Explorations:

  1. Go to Explore (left sidebar).
  2. Click Blank to start a new exploration.
  3. Drag custom dimensions to Rows.
  4. Drag metrics (e.g., Users, Conversions) to Values.
  5. Apply filters to isolate AI traffic.

Explorations let you build custom reports without touching code. This is where you'll do most of your AEO analysis.

Building Your AEO Dashboard

Once custom dimensions are set up, build a dashboard that tracks AEO performance.

Essential cards:

  1. AI Traffic by Source: Users from ChatGPT, Perplexity, Claude, etc.
  2. AI Traffic by Model: GPT-4o vs. GPT-3.5, Perplexity Pro vs. free, etc.
  3. Top AI Queries: What questions get your content cited?
  4. Citation Type Breakdown: Direct citations vs. search results.
  5. AI Intent Performance: Which intent types convert best?
  6. AI Conversion Rate: Do AI visitors convert better or worse than organic?

Create the dashboard in GA4:

  1. Go to DashboardsCreate New Dashboard.
  2. Name it: "AEO Performance".
  3. Add cards using your custom dimensions.
  4. Save it.

Now you have a single view of your AEO performance. Check it weekly.

Connecting AI Traffic to Content Performance

Custom dimensions show you where AI traffic comes from. But you also need to know which content drives the most AI citations.

Create a report that combines:

  • Page path (which article)
  • AI source (which engine cited it)
  • Users (how many visitors)
  • Conversions (did they convert)

In Explorations:

  1. Drag Page Title/Path to Rows.
  2. Drag AI Source to Columns.
  3. Drag Users and Conversions to Values.
  4. Filter to only AI traffic (using a custom dimension filter).

Now you see a matrix: each article, broken down by AI source, with user and conversion counts.

This tells you which articles are getting cited and which AI engines cite them most.

Correlating AI Traffic with Organic Traffic

AEO and SEO are related but different. AEO can drive organic traffic if the AI engine links to your content. But not all AI citations result in clicks.

Use custom dimensions to correlate AI traffic with traditional organic traffic:

  1. Create a report with Source/Medium (organic, direct, referral, etc.).
  2. Add AI Source as a secondary dimension.
  3. Compare metrics: users, bounce rate, conversion rate.

This shows you whether AI-referred visitors behave differently than other organic visitors.

Example insight: Visitors from Perplexity citations have a 40% higher conversion rate than Google organic. This tells you to invest more in Perplexity AEO.

Troubleshooting: Why Your Custom Dimensions Aren't Showing Data

Common issues and fixes:

Dimensions Registered but No Data

Cause: GTM tag isn't firing or parameters aren't being sent.

Fix:

  1. Use Tag Assistant to verify the GA4 tag is firing.
  2. Check that event parameters match the parameter names you registered in GA4 (case-sensitive).
  3. Wait 24-48 hours for data to appear in reports.

Dimensions Showing "(not set)"

Cause: Variables are returning empty values.

Fix:

  1. Check that your GTM variable (e.g., AI Source Detector) is correctly configured.
  2. Test the variable using GTM's Preview mode.
  3. Verify that your JavaScript code is syntactically correct.

Dimensions Not Appearing in Reports

Cause: Custom dimension scope is wrong (e.g., you set it to User but you need Event).

Fix:

  1. Go to AdminCustom Definitions.
  2. Check the scope of each dimension.
  3. If wrong, delete and recreate with the correct scope.

Referrer Data Missing

Cause: AI engine doesn't send referrer headers (e.g., mobile apps).

Fix: This is unavoidable for some traffic. Use server-side tracking (Option B) to capture data that browser-level tracking misses.

Interpreting Your AEO Data

Once custom dimensions are working, here's what to look for:

High AI Source Traffic + Low Conversions

Insight: You're getting cited a lot, but visitors aren't converting.

Action: Analyze the AI queries that bring traffic. Are they low-intent queries (e.g., "what is AEO?") or high-intent (e.g., "best AEO tools")? Optimize your content to answer high-intent queries better.

Direct Citations Outperform Search Results

Insight: When AI engines directly cite you, visitors convert more.

Action: Focus on getting direct citations. This means creating content that AI engines want to quote, not just find in search results.

One AI Model Dominates

Insight: GPT-4o sends 70% of AI traffic, but GPT-3.5 sends 20%.

Action: GPT-4o users trust your content. Double down on that audience. Also, investigate why GPT-3.5 users are less likely to cite you—maybe your content is too technical or too simple.

Certain Intents Convert Better

Insight: How-to content converts at 8%, but comparative content converts at 2%.

Action: Create more how-to content. Deprioritize comparative content unless it's a strategic priority.

Advanced: Combining AI Data with GSC Data

Google Search Console shows you search queries and rankings. GA4 shows you traffic and conversions. Together, they tell you whether AI citations are driving new traffic or cannibalizing organic traffic.

Link GA4 with Google Search Console to see search data directly in GA4.

Then create a report:

  1. Rows: Query (from GSC)
  2. Columns: Source (organic, AI)
  3. Values: Impressions, Clicks, Conversions

This shows you which queries drive traffic from both organic and AI sources—and whether they're complementary or competitive.

Key Takeaways

Here's what you need to remember:

The Five Custom Dimensions:

  1. AI Source – Which engine (ChatGPT, Perplexity, etc.)
  2. AI Model – Which version (GPT-4o, Pro, etc.)
  3. AI Query – What question prompted the citation
  4. Citation Type – Direct citation or search result
  5. AI Intent – What type of answer (how-to, comparative, etc.)

The Setup Process:

  1. Register dimensions in GA4 admin.
  2. Create GTM tags to capture and send dimension data.
  3. Test with Tag Assistant before publishing.
  4. Wait 24-48 hours for data to appear.
  5. Build reports and dashboards to analyze AEO performance.

What This Enables:

  • See which AI engines cite you most.
  • Understand what queries drive AI citations.
  • Measure whether AI traffic converts.
  • Optimize content for AI, not just search engines.
  • Correlate AEO with SEO to see the full organic picture.

The Bottom Line:

Default GA4 treats all traffic the same. AEO is not SEO. AI traffic behaves differently, comes from different sources, and needs different optimization.

Adding these five custom dimensions takes 30 minutes. It gives you visibility into a traffic channel that most founders are ignoring.

If you're shipping content to get cited by AI, you need to measure it. These dimensions are how.

Next Steps

Once your custom dimensions are live and collecting data, read the 5 GA4 reports every busy founder should bookmark to learn which reports matter most.

If you want to go deeper on GA4 events, track beyond pageviews with GA4 events for SEO.

And if you need a broader AEO strategy, check out AEO basics for e-commerce and the 100-day AEO diary for a real founder's playbook.

Ship it. Measure it. Optimize it.

Free weekly newsletter

Get the next one on Sunday.

One short email a week. What is working in SEO right now. Unsubscribe in one click.

Subscribe on Substack →
Keep reading