AI Traffic Regex Generator: Free GA4 Patterns

AI Traffic Regex Generator

Get the regex that finds visits from ChatGPT, Perplexity, Claude and other AI assistants in GA4, Looker Studio and BigQuery.

GA4 already has a built-in "AI Assistant" channel. Check it first, under Session primary channel group in your acquisition reports.

Use this pattern for assistants that channel may miss, for Explorations, segments and filters, for Looker Studio and BigQuery, and for older data.

Assistants to match

The pattern is tested against

One host name per line, without https://. Up to 50.

Select at least one assistant, or add a host name, to get a pattern.

Try it

What a pattern cannot see

Some assistant apps and privacy settings send no referrer. Those visits show up as Direct, and no regex can recover them.

Visits from Google AI Overviews and AI Mode arrive from Google Search, so analytics counts them as Organic Search, not as AI.

Only ChatGPT documents a tag on its links (utm_source=chatgpt.com). Host names marked "reported, not confirmed" come from third-party reports, not from the assistant's own documentation.

An AI traffic regex generator builds the pattern you paste into GA4, Looker Studio or BigQuery to find visits from ChatGPT, Perplexity, Claude and other AI assistants. You tick the assistants, choose what the pattern is tested against, check it on sample lines, and copy it. It suits marketers and analysts who report on AI referrals.

What Is a Regex for AI Traffic?

A regex for AI traffic is a text pattern that matches the source or referrer of visits sent by AI assistants, so your analytics can group them. Instead of listing each host separately, the pattern joins them with the "or" symbol, so one value matches chatgpt.com, perplexity.ai, claude.ai and more.

In GA4 you paste the pattern as the value of a "matches regex" condition. Two things can be tested. One is the session source, which is a host name such as chatgpt.com. The other is the full referrer address, such as https://chatgpt.com/ followed by a path. The generator builds the right shape for either.

Dots in host names are escaped, so chatgpt.com cannot accidentally match a lookalike with a different character in place of the dot. The pattern also has start and end markers, so it matches the whole value instead of any longer domain that merely contains an assistant's name.

Do You Still Need a Regex if GA4 Has an AI Assistant Channel?

Yes, in several cases. GA4 already has a built-in "AI Assistant" channel, and you should check it first under Session primary channel group in your acquisition reports. A custom pattern covers what that channel does not.

Use the generated pattern when you need to:

  • catch assistants the built-in channel may miss;
  • build Explorations, segments and filters around AI visits;
  • report on AI traffic in Looker Studio or query it in BigQuery;
  • group older data that was collected before a channel rule existed.

How to Use the AI Traffic Regex Generator

You can get a working pattern in about a minute by following these steps.

  1. Under Assistants to match, tick the assistants you want. Click Select all or Select none to start from a clean slate. Well-known assistants appear under Best known, the rest under Other assistants.
  2. Under The pattern is tested against, choose a source name (such as GA4 Session source, chatgpt.com) or a full referrer address (https://chatgpt.com/...).
  3. Decide on the two checkboxes: Match subdomains too (www.perplexity.ai as well as perplexity.ai) and Include older addresses (such as chat.openai.com). Both are on by default.
  4. Optional: add hosts under Extra host names to match. Type one per line, without https://, up to 50.
  5. Read Your pattern, check the length note under it, and click Copy.
  6. Open Try it, paste sources or referrer addresses one per line (or click Load examples), and check the Line, Result and Assistant columns.
  7. Scroll to the ready-made snippets and follow the numbered steps for a GA4 custom channel group, a GA4 Explore segment or filter, a Looker Studio CASE formula, or a BigQuery WHERE clause.

Worked Example: Matching ChatGPT and Perplexity

Say you only care about two assistants. You tick ChatGPT and Perplexity, keep "a source name" selected, and leave subdomains and older addresses on. The pattern lists chatgpt.com, chat.openai.com and perplexity.ai, each with escaped dots, plus an allowance for a prefix such as www.

Now paste three lines into Try it:

  • chatgpt.com: matched, assistant ChatGPT.
  • www.perplexity.ai: matched, assistant Perplexity, because subdomains are on.
  • google.com: not matched.

Untick Match subdomains too and the second line stops matching. That is the point of testing first: you see exactly what a setting changes before it touches your reports. Untick Include older addresses and a line such as chat.openai.com would drop out, which matters if you analyze data from before ChatGPT moved to its current domain.

How Do You Read and Act on the Results?

Your result is one pattern, a length note, a test table and copy-ready snippets. Each part answers a different question.

The pattern and its length

GA4 limits a regex value to 256 characters. The length note shows where you stand. If you go over, a warning appears with a shorter alternative that leaves out older addresses, and you can click Use the shorter pattern. You can also untick assistants that never appear in your reports.

The test table

Each pasted line gets a result and, when it matches, the assistant it belongs to. A line you expected to match but did not usually has one of three causes: the assistant is not ticked, subdomains are off, or you are testing a full address while the mode is set to source name.

The snippets

Pick the snippet for where you work. In a GA4 custom channel group, you add a new channel, name it, set the condition to match regex and paste the pattern. In an Explore segment, you add a session segment with the same kind of condition. The Looker Studio snippet wraps the pattern in a CASE formula, and the BigQuery snippet puts it in a WHERE clause against the lowercased value.

SituationSetting to chooseWhy
Filtering on GA4 Session sourceSource nameValue is a bare host
Filtering on a page referrer fieldReferrer addressValue is a full URL
Pattern is over 256 charactersShorter patternDrops older hosts

Who Is This Useful For?

Anyone who has to explain how much traffic comes from AI assistants will save time here. A few typical situations:

  • SEO and content teams who want a segment of AI visits to see which pages assistants send people to, then compare that with AI search readiness scores for those pages.
  • Analysts who build Looker Studio dashboards and need a channel rule that works outside the GA4 interface.
  • Data teams who query the GA4 export in BigQuery and want a clean filter without hand-writing escapes.
  • Agencies who report AI referrals for several clients and want the same pattern each time.
  • Site owners who see a new assistant in their referrals and want to add its host in the extra hosts box.

Referral visits are only half the picture. To see which AI crawlers fetch your pages, a tool such as the AI bot log analyzer reads server logs, and the AI crawler access checker shows whether your robots.txt lets those bots in.

Best Practices, Common Mistakes and Troubleshooting

Check the built-in channel first

Compare your custom channel with the built-in AI Assistant channel for the same dates. If the numbers are close, you may not need the custom group. If yours is higher, the difference shows which assistants the built-in rule misses.

Match the mode to the field

The most common mistake is pasting a source-name pattern into a field that holds full URLs, or the reverse. Always choose the mode that matches the field you will paste into, then test with a real value copied from your report.

Keep older addresses for historical reports

If you look at data from before an assistant changed domains, leave Include older addresses on. Turn it off only when you need the shorter pattern for the character limit.

Add new assistants yourself

New assistants appear often. Type the host without https:// under Extra host names, one per line. Invalid entries are flagged so you can fix them, such as a typo or a full path.

Treat unconfirmed hosts with care

Hosts marked "reported, not confirmed" come from third-party reports, not from the assistant's own documentation. Include them if you see that traffic, but verify them against your own referral data before reporting.

Name and place the channel sensibly

In a GA4 custom channel group, order matters: channels are evaluated from the top, so a broader rule above your AI channel can take the visits first. Move the AI channel above anything that would claim those sources.

What a Pattern Cannot See

A regex can only match what your analytics recorded, so some AI visits stay invisible. Some assistant apps and privacy settings send no referrer. Those visits are logged as Direct, and no pattern can recover them. Claude, for instance, often sends no referrer, so part of its traffic lands in Direct.

Visits from Google AI Overviews and AI Mode arrive from Google Search, so analytics counts them as Organic Search. The generator covers assistant hosts such as Gemini, but not those search features.

Of the assistants listed, only ChatGPT documents a tag on its links (utm_source=chatgpt.com). For that reason, treat your AI figures as a minimum count, and use them to see trends, not to claim a full total.

Get Your Pattern

Pick your assistants, test a few real referrers, and copy the snippet for your platform. Once your AI segment is running, the AI SEO tools collection has more ways to check how AI systems reach and read your pages. Use the AI traffic regex generator on this page and have a working GA4 pattern in a minute.

Frequently Asked Questions

How do I track ChatGPT traffic in GA4?
Check the built-in AI Assistant channel first, then use a regex for anything it misses. Tick ChatGPT in the generator, copy the pattern, and paste it as the value of a matches regex condition in a custom channel group or Explore segment. Leave older addresses on so chat.openai.com visits are included.
Should I choose source name or full referrer address?
Choose source name for GA4 Session source, which holds a host such as chatgpt.com. Choose full referrer address when the field holds complete URLs. Paste a real value from your report into Try it to confirm the pattern matches before you copy it.
Why is my AI traffic regex longer than GA4 allows?
GA4 limits a regex value to 256 characters, and many assistants, subdomains and older hosts can pass that. The generator shows a warning and offers a shorter pattern without older addresses. You can also untick assistants that never appear in your reports.
Can a regex find traffic from Google AI Overviews or AI Mode?
No. Visits from Google AI Overviews and AI Mode arrive from Google Search, so analytics counts them as Organic Search. No pattern can separate them. The generator covers assistant hosts such as Gemini, but not those search features.
Why do some AI visits still show as Direct after I use the pattern?
Some assistant apps and privacy settings send no referrer, so GA4 records the visit as Direct. No regex can recover those visits. Claude often behaves this way, so treat your AI traffic numbers as a minimum count, not a full total.
Is the AI Traffic Regex Generator free, and can I test a pattern first?
Yes, the generator is free and needs no sign-in. In the Try it box, paste sources or referrer addresses one per line, or click Load examples. Each line shows whether it matched and which assistant it belongs to.
Recommended

Explore VPN options

A VPN changes your network exit. It does not guarantee anonymity.

Hide Your IP Encryption Network coverage
Protect My IP Now