← Back to insights
Guide · #739

How to Track AI Referral Traffic in PostHog

Step-by-step guide to setting up UTM parameters and events in PostHog to capture ChatGPT, Claude, and Perplexity referral traffic. Track AI-driven visitors.

Filed
May 11, 2026
Read
17 min
Author
The Seoable Team

How to Track AI Referral Traffic in PostHog

Your product is shipping. Traffic is coming from somewhere. But if that somewhere includes ChatGPT, Claude Opus, or Perplexity, you're probably flying blind.

AI models don't pass referrer headers the way a normal link does. They cite your content, users click through, and those visitors land on your site as direct traffic. No attribution. No visibility. No way to know if your SEO efforts are feeding AI models that are driving real users to you.

PostHog can fix that. With proper UTM setup and event tracking, you can catch every AI referral, measure its impact, and double down on what's working. This guide walks you through the exact setup.

Why AI Referral Traffic Matters Now

ChatGPT, Claude, and Perplexity are becoming search engines. They cite sources. Users click those sources. That's traffic.

But here's the brutal truth: if you're not tracking it, you can't measure it. And if you can't measure it, you can't optimize for it.

Traditional analytics treat AI referrals as direct traffic or dark traffic. Google Analytics sees a visitor with no referrer and assumes they typed your URL directly. They didn't. They clicked a link in an AI response.

PostHog's event system and UTM parameter handling let you break that down. You can see exactly how many users came from AI citations, what they did on your site, and whether they converted. This is the difference between guessing and knowing.

Moreover, as we've covered in GA4 Events for SEO: What to Track Beyond Pageviews, custom events reveal user intent and content quality in ways pageviews never will. PostHog's event model is built for exactly this kind of granular tracking.

Prerequisites: What You Need Before Starting

Before you set up AI referral tracking in PostHog, make sure you have these in place:

PostHog Account and Installation You need a PostHog instance running. If you haven't installed PostHog yet, PostHog's web analytics dashboard documentation covers the basics. The free tier is sufficient for this setup.

Your Website with PostHog SDK The PostHog JavaScript SDK must be installed on your site. This is non-negotiable. Without it, PostHog can't see the traffic or events.

Understanding of UTM Parameters You should know what UTM parameters are: utm_source, utm_medium, utm_campaign, utm_content, and utm_term. These are URL parameters that tell analytics where traffic came from. If you're new to UTMs, Semrush's guide on referral traffic explains the concept clearly.

Access to Your Content You need to be able to add UTM parameters to the URLs in your content. If your content lives in a CMS, blog platform, or documentation site, you need edit access.

Basic PostHog Event Knowledge Understanding how PostHog captures events will help. You don't need to be an expert, but knowing that events are custom actions users take on your site is foundational.

If you're setting up analytics from scratch, Setting Up Google Analytics 4 for SEO Tracking from Day One covers the broader tracking philosophy that applies to PostHog as well.

Step 1: Define Your AI Referral Sources and UTM Strategy

Before you build anything in PostHog, you need a naming convention. This matters because consistency is what makes data useful.

Decide which AI platforms you want to track. The main ones are:

  • ChatGPT (OpenAI's web interface and API)
  • Claude (Anthropic's chat interface)
  • Perplexity (AI search engine)
  • Copilot (Microsoft's AI, increasingly cited in Bing results)
  • Gemini (Google's AI model)

For each, you'll create a consistent UTM structure. Here's what we recommend:

UTM Structure for AI Referrals:

utm_source=ai
utm_medium=citation
utm_campaign=[ai_platform]
utm_content=[content_type_or_topic]

So a link to your blog post about SEO that you want to track from ChatGPT would look like:

https://yoursite.com/blog/seo-guide?utm_source=ai&utm_medium=citation&utm_campaign=chatgpt&utm_content=seo-guide

And the same link for Claude:

https://yoursite.com/blog/seo-guide?utm_source=ai&utm_medium=citation&utm_campaign=claude&utm_content=seo-guide

This structure gives you flexibility. You can filter by ai source to see all AI traffic. You can segment by campaign to compare ChatGPT vs. Claude. You can track content performance across AI platforms.

Write this down. You'll use it consistently across all your content.

Note: You're doing this because AI models won't naturally pass referrer information. The UTM parameters are your way of manually attributing traffic that would otherwise appear as direct.

Step 2: Add UTM Parameters to Your Content

Now you need to actually add these UTM parameters to the URLs in your published content.

Where does this happen? Everywhere your content lives:

  • Blog posts
  • Documentation
  • Product pages
  • Case studies
  • Any page you want AI models to cite

For Blog Posts and CMS Content:

If you use a CMS like WordPress, Webflow, or Ghost, edit each post and add the UTM parameters to any internal links you want to track. Most CMSs let you add query parameters directly in the URL field.

Example: If you have a blog post about keyword research, and that post links to your pricing page, make the link:

https://yoursite.com/pricing?utm_source=ai&utm_medium=citation&utm_campaign=chatgpt&utm_content=keyword-research

For Documentation Sites:

If you use Docs, Notion, or a static site generator, the process is similar. Add the UTM parameters to links in your content.

For Pages You Can't Edit:

If you have content on Medium, Dev.to, or other platforms you don't control, you can't add UTMs directly. But you can still track them through PostHog events (more on that in Step 4).

Pro Tip: Use a URL Builder

Don't manually type UTM parameters. Use Google's Campaign URL Builder or a similar tool. It reduces typos and keeps your parameters consistent. Paste in your base URL, fill in the UTM fields, and copy the result.

Alternatively, if you're using Seoable's AI-generated content, The Busy Founder's Brief Template for AI-Generated Content includes guidance on embedding UTMs into your AI prompts so they're generated automatically.

Step 3: Set Up PostHog UTM Tracking

PostHog automatically captures UTM parameters if they're in the URL. You don't need to do anything special to make this happen—it's built in.

However, you should verify that UTM capture is enabled and configure how PostHog displays this data.

Verify UTM Capture is Enabled:

  1. Log into your PostHog instance
  2. Go to SettingsProject SettingsData Management
  3. Look for the UTM Parameters section
  4. Confirm that UTM capture is toggled on (it should be by default)
  5. If you have custom UTM parameters beyond the standard five, add them here

PostHog will now automatically capture:

  • utm_source
  • utm_medium
  • utm_campaign
  • utm_content
  • utm_term

These become filterable properties in PostHog. You can use them to segment traffic, build reports, and create funnels.

Access UTM Data in PostHog:

Once UTM capture is enabled, you can see it in several places:

  1. Web Analytics Dashboard: Go to AnalyticsWeb Analytics. You'll see a traffic overview. Click on any traffic source to see UTM breakdown.

  2. Events Table: Go to Events. Create a new view and add filters for utm_source = ai. This shows you every pageview from AI referrals.

  3. Insights: Create a new insight and use UTM properties in your filters and breakdowns. For example, filter by utm_campaign to compare ChatGPT vs. Claude traffic.

The PostHog web analytics dashboard documentation has detailed screenshots if you need visual guidance.

Step 4: Create Custom Events to Track AI Visitor Behavior

UTM parameters tell you where traffic came from. Custom events tell you what they did.

When an AI-referred visitor lands on your site, do they:

  • Read the full article?
  • Click a CTA?
  • Sign up?
  • Bounce immediately?

Custom events answer these questions.

Here's what to track:

Event 1: AI Referral Landing

Fire an event the moment a visitor with AI UTMs lands on your site. This gives you a clean count of AI-referred visitors.

In PostHog's JavaScript SDK, add this code to your site's header or in a global script:

if (typeof window !== 'undefined') {
  const params = new URLSearchParams(window.location.search);
  if (params.get('utm_source') === 'ai') {
    posthog.capture('ai_referral_landing', {
      utm_campaign: params.get('utm_campaign'),
      utm_content: params.get('utm_content'),
      page_title: document.title,
      referrer: document.referrer
    });
  }
}

This event fires once per session when an AI-referred visitor arrives. The properties capture which AI platform and content type drove them.

Event 2: Content Engagement

Track when visitors scroll past 50% of an article or spend more than 30 seconds on a page. This tells you if AI-referred traffic is actually reading your content.

let engagementTracked = false;

window.addEventListener('scroll', function() {
  if (!engagementTracked) {
    const scrollPercent = (window.scrollY / (document.documentElement.scrollHeight - window.innerHeight)) * 100;
    if (scrollPercent > 50) {
      posthog.capture('ai_content_engagement', {
        scroll_depth: Math.round(scrollPercent),
        page_title: document.title
      });
      engagementTracked = true;
    }
  }
});

Event 3: CTA Clicks

Track clicks on buttons, links, or CTAs that matter to your business. Sign-up buttons, pricing links, demo requests, etc.

document.querySelectorAll('[data-track-cta]').forEach(button => {
  button.addEventListener('click', function() {
    posthog.capture('ai_cta_click', {
      cta_text: this.innerText,
      cta_type: this.getAttribute('data-track-cta'),
      page_title: document.title
    });
  });
});

Then add data-track-cta="signup" (or whatever type) to your buttons in HTML.

Event 4: Conversion

Track actual conversions. Did they sign up? Make a purchase? Download something?

posthog.capture('ai_conversion', {
  conversion_type: 'signup', // or 'purchase', 'download', etc.
  conversion_value: 0, // if applicable
  utm_campaign: new URLSearchParams(window.location.search).get('utm_campaign')
});

Call this event in your conversion confirmation page or thank-you screen.

As we've covered in GA4 Events for SEO: What to Track Beyond Pageviews, these custom events are what separate vanity metrics from actionable data. You're measuring intent and outcome, not just pageviews.

Step 5: Build PostHog Insights and Dashboards

Now that you're capturing UTM data and custom events, it's time to visualize it.

Create an AI Referral Dashboard:

  1. Go to DashboardsNew Dashboard
  2. Name it "AI Referral Tracking"
  3. Add these insights:

Insight 1: AI Traffic Over Time

  • Chart type: Line chart
  • Event: Pageview
  • Filter: utm_source = ai
  • Breakdown: utm_campaign
  • This shows you traffic trends by AI platform

Insight 2: AI Traffic by Content

  • Chart type: Bar chart
  • Event: Pageview
  • Filter: utm_source = ai
  • Breakdown: utm_content
  • This shows which content pieces drive the most AI referrals

Insight 3: AI Visitor Engagement Funnel

  • Chart type: Funnel
  • Events in order:
    1. ai_referral_landing
    2. ai_content_engagement
    3. ai_cta_click
    4. ai_conversion
  • This shows you the drop-off at each stage

Insight 4: Conversion Rate by AI Platform

  • Chart type: Pie chart or table
  • Event: ai_conversion
  • Breakdown: utm_campaign
  • This shows which AI platforms drive the highest-quality traffic

Insight 5: Session Duration for AI Referrals

  • Chart type: Number
  • Event: Session
  • Filter: utm_source = ai
  • Breakdown: None (just the aggregate)
  • This shows how long AI-referred visitors stay on your site

Add these to your dashboard. Pin it to your sidebar so you can check it daily.

This is similar to what we recommend in SEO Reporting Basics: The 5 Metrics That Tell You If It's Working—focus on the metrics that matter, ignore the rest.

Step 6: Set Up Alerts for AI Traffic Spikes

PostHog can alert you when something unusual happens. Use this to catch big AI referral events.

Create an Alert:

  1. Go to AlertsNew Alert
  2. Set the condition:
    • Metric: ai_referral_landing event count
    • Condition: "Greater than" your normal daily average
    • Threshold: 2x your daily average (or whatever makes sense for your traffic)
  3. Set the notification: Email or Slack
  4. Save

Now, if a popular AI model cites your content and drives a traffic spike, you'll know immediately.

You can also use PostHog's AI investigation features to dig into spikes automatically. PostHog's AI assistant can help you understand what changed and why traffic moved.

Step 7: Compare AI Traffic to Organic and Other Channels

AI referrals are one channel. You need to see how they stack up against organic search, direct traffic, and other sources.

Create a Channel Comparison Insight:

  1. Go to InsightsNew Insight
  2. Event: Pageview
  3. Breakdown: utm_source (this breaks down by source)
  4. Filter: None (see all traffic)
  5. Chart type: Bar chart or table

You'll see something like:

  • organic: 1,200 pageviews
  • ai: 340 pageviews
  • direct: 890 pageviews
  • referral: 120 pageviews

Now you can see AI's contribution to your overall traffic. Is it 10% of your traffic? 30%? This context matters.

If you're also tracking organic search through Google Search Console integration, you can compare how AI citations are performing relative to traditional organic search.

Step 8: Track AI Referrals from Multiple Platforms Simultaneously

AI models often cite the same content. You might see traffic from ChatGPT, Claude, and Perplexity all in the same day.

To track them all without confusion, stick to your UTM naming convention and use PostHog's filtering.

View Traffic by AI Platform:

  1. Go to Web AnalyticsDashboard
  2. Click the traffic chart
  3. Add a filter: utm_campaign contains "chatgpt" OR "claude" OR "perplexity"
  4. Breakdown by: utm_campaign

You'll see a side-by-side comparison of each platform's traffic.

Segment Your Funnel by Platform:

  1. Create a funnel insight (ai_referral_landing → ai_conversion)
  2. Breakdown by: utm_campaign
  3. You'll see conversion rates for each AI platform

This tells you which platforms are sending the highest-quality traffic. Maybe ChatGPT visitors convert at 5%, but Claude visitors convert at 12%. That's actionable.

As noted in Referral Traffic and SEO - Moz, understanding the quality of referral traffic is more important than volume. PostHog's event tracking lets you measure quality directly.

Step 9: Integrate PostHog Data with Your Other Tools

PostHog doesn't exist in isolation. You probably also use Google Analytics, your email tool, or a CRM.

Export PostHog Data:

PostHog can export data to:

  • Google BigQuery
  • Segment
  • Webhook (for custom integrations)

If you want to combine AI referral data with your other analytics, export to BigQuery and query across sources.

Send AI Referral Events to Your CRM:

If a PostHog visitor converts, you might want to flag them in your CRM as "AI-referred." Use a webhook to send conversion events to your CRM's API.

Example webhook payload:

{
  "event": "ai_conversion",
  "user_id": "user_123",
  "utm_campaign": "chatgpt",
  "timestamp": "2024-01-15T10:30:00Z"
}

Your CRM can then use this data to segment campaigns or personalize follow-up.

Step 10: Iterate Based on Data

Now you have the infrastructure. Use it.

Check your AI referral dashboard weekly. Ask:

  1. Which content drives the most AI referrals? Double down on that topic.
  2. Which AI platform sends the best traffic? If Claude visitors convert at 2x the rate of ChatGPT visitors, optimize for Claude.
  3. Where do visitors drop off? If 80% land but only 20% engage, your content might not match user intent. Fix it.
  4. What's your cost per AI-referred conversion? If you're spending $100/month on SEO and getting 10 AI conversions, that's $10 per conversion. Is that good? Only you know.

Use The 5 GA4 Reports Every Busy Founder Should Bookmark as a reference for the reporting mindset—focus on metrics that drive decisions, not metrics that look good.

If you're generating content specifically to feed AI models, The Busy Founder's AI Stack for SEO: Three Tools, Zero Bloat covers how to create content that ranks in both traditional search and AI responses.

Common Pitfalls and How to Avoid Them

Pitfall 1: Inconsistent UTM Naming

If you spell "chatgpt" one way one day and "ChatGPT" another, PostHog treats them as separate sources. Your data fragments.

Fix: Use lowercase, hyphens instead of spaces. Document your convention. Use a URL builder tool to enforce consistency.

Pitfall 2: Forgetting to Add UTMs to All Links

You add UTMs to your homepage but not your blog. You track some content but not others. Your data is incomplete.

Fix: Create a checklist. Before publishing anything, add UTMs. Make it part of your workflow.

Pitfall 3: Not Tracking Events

You set up UTM parameters but never create custom events. You see traffic but not what those visitors do.

Fix: Start with the four events in Step 4. You can add more later. But you need at least landing, engagement, and conversion.

Pitfall 4: Confusing AI Traffic with Direct Traffic

If you don't add UTMs, PostHog (and Google Analytics) will classify AI referrals as direct traffic. You'll never know the difference.

Fix: Always add UTMs to content you want to track. No exceptions.

Pitfall 5: Not Checking Your Data

You set everything up and then never look at it. Your dashboard sits unused.

Fix: Schedule a weekly 15-minute check-in. Look at the dashboard. Ask one question. Act on one insight.

Why PostHog for AI Referral Tracking?

You could use Google Analytics. Google Analytics is free and handles UTM tracking well.

But PostHog has advantages:

  1. Event-first design: PostHog's entire architecture is built around custom events. GA4 can do it, but it feels bolted on.
  2. No data sampling: PostHog doesn't sample your data. Every event counts. GA4 samples at high traffic volumes.
  3. Privacy-first: PostHog can run on your own servers. No third-party tracking cookies.
  4. Faster queries: PostHog's dashboards load faster than GA4, especially with large datasets.
  5. Built-in AI analysis: PostHog can automatically investigate anomalies and spikes.

For a founder tracking AI referrals, PostHog is purpose-built. GA4 works, but PostHog works better.

If you're setting up your full tracking stack, The Free SEO Tool Stack Every Founder Should Set Up Today covers how PostHog fits alongside Google Search Console and other tools.

Measuring Success: What Good Looks Like

After one month of tracking AI referrals in PostHog, you should see:

  1. Baseline: You know how much traffic comes from AI. It might be 5% of your total. That's your baseline.
  2. Content Performance: You know which content pieces drive the most AI referrals. You can rank them.
  3. Quality Signal: You know whether AI-referred traffic converts. If it converts at the same rate as organic search, AI citations are as valuable as rankings.
  4. Platform Insights: You know which AI platforms send the best traffic. This informs where you focus your content strategy.
  5. Trend: You can see if AI referrals are growing month-over-month. If they're flat, your content strategy isn't working. If they're growing, you're onto something.

Good AI referral tracking isn't about hitting a specific number. It's about having visibility. You're no longer guessing. You're measuring.

Next Steps: From Tracking to Optimization

Once you have tracking in place, optimization becomes possible.

If you're generating content specifically to rank in AI responses, that's a different game than traditional SEO. As covered in Why Bing Webmaster Tools Matters Now That Copilot Cites It, AI models increasingly pull from Bing's index. Understanding which platforms feed which AI models changes your strategy.

You might also want to set up Google Search Console integration to see which keywords are driving both traditional organic and AI referrals. Keywords that appear in AI responses might have different characteristics than keywords that rank in Google.

Finally, if you're scaling content, IndexNow Setup: Pinging Bing and Yandex for Faster Crawls ensures your new content gets indexed quickly. Faster indexing means faster AI citations.

Summary: The AI Referral Tracking Checklist

Here's what you've built:

UTM Strategy: Defined naming convention for AI sources (utm_source=ai, utm_campaign=[platform])

Content Updates: Added UTM parameters to all published content

PostHog Configuration: Enabled UTM capture and verified it's working

Custom Events: Implemented four events (landing, engagement, CTA, conversion)

Dashboard: Built AI referral dashboard with five key insights

Alerts: Set up spike alerts so you know when AI traffic moves

Comparison: Created channel comparison to see AI's share of total traffic

Segmentation: Can filter and break down by AI platform

Integration: Connected PostHog to other tools (optional but recommended)

Iteration: Committed to weekly reviews and data-driven decisions

You now have end-to-end visibility into AI referral traffic. You know where it comes from, what visitors do, and whether it converts.

That's not a guess. That's a fact. And facts drive decisions.

Start tracking this week. Check your dashboard next week. Optimize the week after. That's the founder's way.

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