Skip to content
Free tool

GA4 regex for AI traffic: ChatGPT, Perplexity, Gemini and more

Pick the AI assistants to count and copy a ready regex for the Session source in Google Analytics 4. Add it to a custom channel group above Referral, or use it as an exploration filter, to see visits from ChatGPT, Perplexity, Gemini, Copilot and Claude in one line.

AI assistants to count12 of 12 selected

Optional. Other AI tools as GA4 shows them in Session source, one per line, for example poe.com. Subdomains are included.

Runs in your browser. Nothing you type is sent or stored.

Check that AI bots can reach your site

Result

Ready

Your GA4 regex is ready

319 characters, RE2 syntax accepted by GA4

Counted as AI

Type a value from the Session source column, for example chatgpt.com.

Paste it into a channel group condition (Source matches regex) or an exploration filter. The steps are below.

Read the result as a floor: many AI assistant visits arrive without a referrer and show up as Direct.

Add the regex to GA4

Google renames and moves GA4 menus from time to time, so the labels in your property may differ slightly from the ones below. Look for the closest match; the settings themselves stay the same.

Option 1: a custom channel group

Recommended. AI visits get their own row in the standard acquisition reports, next to Organic Search and Referral.

  1. Open channel groups

    Click Admin (the gear icon at the bottom left). Under Data display, choose Channel groups. You need edit access to the property.

  2. Create a new group

    Click Create new channel group and give it a name, such as Channels with AI. A new group usually starts with a copy of the default channels; if yours starts empty, copy the default group instead.

  3. Add an AI assistants channel

    Click Add new channel and name it AI assistants. Add one condition: Source (in some properties, Session source), then matches regex, then paste the regex. Save the channel.

  4. Move it above Referral

    Choose Reorder and drag AI assistants above Referral. GA4 puts each visit in the first channel whose rules match, so a channel below Referral would never receive these visits. Save the group.

  5. Use it in reports

    Open Reports, then Acquisition, then Traffic acquisition. Click the drop-down on the first column header of the table, which shows the default channel group, and pick your new group. Custom channel groups also apply to past data.

Option 2: a quick exploration filter

No admin changes needed. Good for a one-off look or when you cannot edit channel groups.

  1. Start a blank exploration

    Open Explore, choose Blank and set the date range you want to look at.

  2. Add dimensions and metrics

    Import Session source and Landing page as dimensions, and Sessions, Engaged sessions and Key events as metrics. Drag them into Rows and Values.

  3. Filter by the regex

    Under Filters, choose Session source, then matches regex, paste the pattern and apply. Only AI assistant sources remain. Standard reports accept the same filter where the matches regex option is offered.

What the numbers mean

  • It is a floor. Many AI assistant visits arrive without a referrer, for example links opened from a desktop or mobile app or copied into a new tab, and GA4 counts them as Direct.
  • Some assistants add utm_source=chatgpt.com or a similar tag to their links. GA4 then records the tag as the source, which this pattern also matches.
  • Sources are matched in lower case, the way GA4 records referring domains. If you tag your own links, use lower-case utm_source values.
  • New assistants appear often. Add them under Extra sources until they are part of this list.

How it works

  1. Choose the assistants

    Every AI assistant we track is selected. Clear the ones you do not want, and add other AI tools by the domain GA4 shows in the Session source column.

  2. Copy the regex

    The pattern matches each assistant’s domain with or without www. or another subdomain, plus short source names GA4 sometimes records, such as chatgpt. Lookalike domains do not match.

  3. Add it to GA4

    Create a custom channel group with an AI assistants channel placed above Referral, or filter an exploration by Session source. Both are explained step by step below the tool.

Frequently asked questions

ChatGPT visits usually have the source chatgpt.com and land in the Referral channel, mixed with every other site that links to you. Create a custom channel group with an AI assistants channel whose source matches this regex, place it above Referral, and pick that group in the Traffic acquisition report.

Many visits from AI assistants carry no referrer, for example links opened from a desktop or mobile app, or copied into a new tab, so GA4 counts them as Direct. Treat the AI assistants channel as a floor, not a total, and watch Direct traffic to the pages AI answers link to.

GA4 uses RE2 syntax, which has no lookaheads or backreferences. The pattern only uses groups, alternation and escaped dots, and it is anchored with ^ and $, so it works with both matches regex and partially matches regex. GA4 may reject very long patterns, so keep the list short.

Measure AI traffic without the setup

Connect GA4 in Citeto to see visits from each AI assistant next to traffic of unknown source, for every site in your workspace.

Sign in to Citeto
GA4 AI traffic regex: track ChatGPT and Perplexity visits