← All posts

How to Track ChatGPT Traffic in GA4, Mixpanel, and Your Own Snippet

A practical guide to tracking ChatGPT, Perplexity, Copilot, and other AI assistant traffic across GA4, Mixpanel, custom snippets, and Aparok.

ChatGPT traffic is no longer a vague "AI might have sent us users" problem. It is measurable if you capture the right source signals at the start of the session.

OpenAI's publisher guidance says websites can track ChatGPT referral traffic in analytics tools such as Google Analytics, and that ChatGPT referral URLs include utm_source=chatgpt.com. That means teams should treat ChatGPT as a measurable acquisition source, not as a mystery bucket inside direct traffic.

This guide shows four ways to track it:

  • GA4: useful for top-level acquisition reporting.
  • Mixpanel: useful for product behavior and conversion analysis.
  • Your own snippet: useful when you need full control over session attribution.
  • Aparok: useful when you want AI traffic detection to be mostly automatic after installing the snippet.

The short answer

To track ChatGPT traffic, capture utm_source, referrer, landing URL, session ID, timestamp, and conversion events. Classify a session as ChatGPT-attributed when the landing URL contains utm_source=chatgpt.com, the referrer domain is chatgpt.com, or another trusted assistant signal identifies ChatGPT as the source.

For Perplexity, Copilot, Gemini, Claude, and other assistants, use the same pattern: check the URL parameters first, then the referrer domain, then source hints passed by your own links or campaigns.

Why AI traffic is easy to miss

Traditional analytics tools were built around search engines, social networks, ads, email, and direct visits. AI assistants do not always behave like those channels.

Common problems:

  • Some visits look direct: if the browser or app does not pass a referrer, analytics tools may classify the session as direct.
  • UTM parameters are inconsistent across assistants: ChatGPT has a clearer signal, but not every assistant adds the same parameters.
  • Session-level attribution gets lost: a user may land from ChatGPT, browse three pages, then convert later without the source in the URL.
  • GA4 and Mixpanel answer different questions: GA4 shows acquisition patterns; Mixpanel shows behavior and conversion paths.

The fix is to persist the source at the session level when the user lands, then attach that source to page views, key actions, and conversions.

What to capture on every landing session

Whether you use GA4, Mixpanel, Aparok, or your own snippet, the minimum useful payload looks like this:

{
  "session_id": "generated-session-id",
  "url": "https://example.com/pricing?utm_source=chatgpt.com",
  "landing_url": "https://example.com/pricing?utm_source=chatgpt.com",
  "referrer": "https://chatgpt.com/",
  "utm_source": "chatgpt.com",
  "utm_medium": "referral",
  "ai_source": "chatgpt",
  "event_type": "page_view",
  "occurred_at": "2026-04-22T10:30:00.000Z"
}

The important part is not the exact field names. The important part is that you store enough evidence to answer: "Did this session start from an AI assistant, and did that session later convert?"

How to track ChatGPT traffic in GA4

GA4 already understands traffic sources, campaigns, source, medium, and referrals. If ChatGPT sends a visit with utm_source=chatgpt.com, GA4 can use that campaign/source data in acquisition reports.

Use GA4 for these questions:

  • How many sessions came from ChatGPT?
  • Which landing pages receive AI assistant traffic?
  • Which assistant source produces engaged sessions?
  • Are AI visitors converting better or worse than SEO visitors?

GA4 setup checklist

  1. Confirm your pages have the Google tag or GTM installed.
  2. Open a URL like /pricing?utm_source=chatgpt.com&utm_medium=referral.
  3. Check Realtime to confirm the visit appears.
  4. Use Traffic acquisition and filter by Session source.
  5. Inspect landing pages for ChatGPT-attributed sessions.

GA4 is usually enough for executive reporting. It is not always enough for product-level attribution because you may need to preserve the AI source across multi-step funnels, anonymous sessions, signups, trials, and conversions.

How to track ChatGPT traffic in Mixpanel

Mixpanel is useful when you want to understand what AI visitors actually do inside your product or funnel.

Mixpanel's JavaScript SDK can automatically attach UTM parameters from the current URL to events fired from that page load. It can also store first-seen UTM values as user profile properties such as initial_utm_source when users are identified.

Use Mixpanel for these questions:

  • Do ChatGPT visitors sign up?
  • Which assistant source creates activated users?
  • Does Perplexity traffic read more pages than ChatGPT traffic?
  • Which AI source leads to workspace creation, checkout, or product usage?

Mixpanel implementation pattern

If you use the browser SDK, make sure your landing page fires a page view or landing event after the SDK initializes:

mixpanel.track("Landing Page Viewed", {
  page_url: window.location.href,
  referrer: document.referrer || null
});

For stronger attribution, normalize assistant sources yourself and add the result as an event property:

function getAiSource() {
  const params = new URLSearchParams(window.location.search);
  const source = (params.get("utm_source") || params.get("source") || "").toLowerCase();
  const referrer = document.referrer.toLowerCase();

  if (source.includes("chatgpt") || referrer.includes("chatgpt.com")) return "chatgpt";
  if (source.includes("perplexity") || referrer.includes("perplexity.ai")) return "perplexity";
  if (source.includes("copilot") || referrer.includes("copilot.microsoft.com")) return "copilot";
  if (source.includes("gemini") || referrer.includes("gemini.google.com")) return "gemini";
  if (source.includes("claude") || referrer.includes("claude.ai")) return "claude";
  return null;
}

const aiSource = getAiSource();

mixpanel.track("Landing Page Viewed", {
  page_url: window.location.href,
  referrer: document.referrer || null,
  ai_source: aiSource,
  is_ai_traffic: Boolean(aiSource)
});

If you track events only from your backend, Mixpanel will not have access to the browser URL automatically. In that case, pass UTM parameters and referrer data from the request into the server-side event.

How to track AI traffic with your own snippet

A custom snippet gives you the most control. The goal is simple: identify the assistant source at landing time, store it for the session, and send it with every relevant event.

Step 1: classify the assistant source

const AI_SOURCE_RULES = [
  { source: "chatgpt", domains: ["chatgpt.com"], tokens: ["chatgpt", "openai"] },
  { source: "perplexity", domains: ["perplexity.ai"], tokens: ["perplexity"] },
  { source: "copilot", domains: ["copilot.microsoft.com", "bing.com"], tokens: ["copilot"] },
  { source: "gemini", domains: ["gemini.google.com"], tokens: ["gemini"] },
  { source: "claude", domains: ["claude.ai"], tokens: ["claude"] }
];

function classifyAiSource(url, referrer) {
  const parsed = new URL(url);
  const params = parsed.searchParams;
  const sourceHint = [
    params.get("utm_source"),
    params.get("source"),
    params.get("ai_source")
  ].filter(Boolean).join(" ").toLowerCase();

  const referrerValue = (referrer || "").toLowerCase();

  return AI_SOURCE_RULES.find((rule) =>
    rule.tokens.some((token) => sourceHint.includes(token)) ||
    rule.domains.some((domain) => referrerValue.includes(domain))
  )?.source || null;
}

Step 2: persist the source for the session

function getSessionId() {
  const key = "ai_session_id";
  const existing = sessionStorage.getItem(key);
  if (existing) return existing;

  const created = crypto.randomUUID();
  sessionStorage.setItem(key, created);
  return created;
}

function getSessionAiSource() {
  const key = "ai_source";
  const existing = sessionStorage.getItem(key);
  if (existing) return existing;

  const detected = classifyAiSource(window.location.href, document.referrer);
  if (detected) sessionStorage.setItem(key, detected);
  return detected;
}

Step 3: send page views and conversions

function trackEvent(eventType, properties = {}) {
  const payload = {
    event_type: eventType,
    session_id: getSessionId(),
    ai_source: getSessionAiSource(),
    is_ai_traffic: Boolean(getSessionAiSource()),
    url: window.location.href,
    referrer: document.referrer || null,
    occurred_at: new Date().toISOString(),
    ...properties
  };

  navigator.sendBeacon("/api/analytics/ingest", JSON.stringify(payload));
}

trackEvent("page_view");

// Example conversion
// trackEvent("conversion", { conversion_type: "signup" });

This is the minimum viable version. A production version should also handle consent, bot filtering, anonymous identity, cross-domain checkout flows, retries, and server-side validation.

Where Aparok fits

Aparok is the simplest path when your goal is not to build another analytics pipeline. Once the Aparok snippet is installed, AI traffic attribution is mostly automatic: it detects assistant-attributed sessions, groups sources like ChatGPT, Perplexity, Copilot, Claude, and Gemini, and shows landing pages, source mix, trend, and conversion context without requiring custom GA4 filters or Mixpanel properties.

Use Aparok when you want to answer:

  • Which AI assistant sent this session?
  • Which landing page did AI traffic enter through?
  • Did the session come from ChatGPT, Perplexity, Copilot, Gemini, Claude, or another assistant?
  • How much of our overall traffic is assistant-attributed?
  • Which pages should we improve to earn more AI citations and assistant referrals?

The practical difference is effort. With GA4 and Mixpanel, you can track the data, but you still need to configure reports, normalize sources, and debug attribution edge cases. With Aparok, the assistant traffic layer is already the product workflow.

Comparison: GA4 vs Mixpanel vs custom snippet vs Aparok

Option Best for Setup effort Weak spot
GA4 Top-level acquisition and channel reporting Low if GA4 is already installed Harder to debug AI-specific session attribution
Mixpanel Funnels, activation, product behavior, conversion analysis Medium Requires careful event design and source normalization
Custom snippet Full control over attribution logic and raw events High You own storage, identity, reporting, and edge cases
Aparok Automatic AI traffic attribution and AI visibility workflow Low after snippet install Focused on AI discovery, not replacing every product analytics use case

Source classification rules for major assistants

Start with these rules and update them as assistants change referral behavior:

  • ChatGPT: utm_source=chatgpt.com, chatgpt.com referrer, or OpenAI/ChatGPT source hint.
  • Perplexity: perplexity.ai referrer or utm_source=perplexity.
  • Copilot: copilot.microsoft.com, Bing/Copilot source hints, or explicit utm_source=copilot.
  • Gemini: gemini.google.com referrer or explicit Gemini source hints.
  • Claude: claude.ai referrer or explicit Claude source hints.

Do not rely on only one signal. Prefer this order: explicit UTM, explicit source parameter, referrer domain, then source hints from your own campaign links.

How to avoid bad attribution

  • Do not overwrite first-touch source too early: preserve the landing source for the session.
  • Do not tag internal links with UTMs: that can corrupt source attribution.
  • Do not treat all direct traffic as AI traffic: only classify when you have evidence.
  • Do not mix sources and assistants: store utm_source separately from normalized ai_source.
  • Do not ignore conversions: sessions are useful, but signups, trials, and purchases are what prove business impact.

Recommended event model

Use a small set of events and consistent properties:

{
  "events": [
    "page_view",
    "signup_started",
    "signup_completed",
    "workspace_created",
    "checkout_started",
    "conversion"
  ],
  "properties": [
    "session_id",
    "landing_url",
    "current_url",
    "referrer",
    "utm_source",
    "utm_medium",
    "utm_campaign",
    "ai_source",
    "is_ai_traffic"
  ]
}

This model works across GA4 custom dimensions, Mixpanel event properties, and your own database. Aparok handles this AI attribution layer directly once the snippet is installed.

FAQ

What UTM source does ChatGPT use?

OpenAI says ChatGPT referral URLs include utm_source=chatgpt.com, which lets publishers track ChatGPT search referral traffic in analytics tools.

Why does ChatGPT traffic sometimes appear as direct?

Some browser, app, privacy, or redirect flows may not pass a useful referrer. If no UTM or referrer signal reaches your analytics tool, the visit can be classified as direct.

Is GA4 enough for ChatGPT traffic tracking?

GA4 is good for acquisition reporting, but product teams often need Mixpanel or Aparok to connect assistant traffic to activation, signup, and conversion behavior.

Is Mixpanel enough for AI traffic attribution?

Mixpanel is strong for funnels and behavior, but you still need to normalize AI sources, persist session attribution, and create reports. Aparok automates the AI traffic layer more directly.

What does Aparok do automatically?

After the Aparok snippet is installed, Aparok detects assistant-attributed sessions, groups traffic by AI source, shows landing pages and trends, and connects AI traffic reporting with AI visibility workflows.

Should I build my own snippet?

Build your own snippet only if you need full control over raw event storage and attribution logic. If your goal is to understand AI assistant traffic quickly, Aparok is the lower-effort path.

Bottom line

ChatGPT traffic is measurable. Start with utm_source=chatgpt.com, preserve the source at the session level, and attach that source to page views and conversions. GA4 gives you channel reporting, Mixpanel gives you behavior analysis, a custom snippet gives you control, and Aparok gives you an automatic AI traffic workflow after snippet installation.

Use Aparok to see which AI assistants are sending traffic, which landing pages they enter through, and where your AI visibility work is turning into real sessions.

Get visibility into your AI traffic

Track how your brand appears in ChatGPT and Perplexity. Measure prompt visibility, citations, and AI-driven traffic with Aparok.

More articles

Keep reading

How to Track ChatGPT Traffic in GA4, Mixpanel, and Your Own Snippet | Aparok Blog