How to track ChatGPT traffic with Google Tag Manager
Short answer: Tag Manager has no traffic report, so you build the label yourself. Enable the built-in Referrer variable, add a RegEx Table variable that outputs “ChatGPT” when the referrer contains chatgpt.com, also check the page address for utm_source=chatgpt.com, and pass the result to GA4 or your form. The catch: the referrer only exists on the landing page, so you must store the label to tie it to a lead. And no tag can see someone who read ChatGPT's answer and then phoned you.
Google Tag Manager is a different kind of platform from Shopify or Wix: it has no reports at all. It doesn't show you traffic; it decides what your other tools get told. That makes it the right place to do one specific job: label a visit as “ChatGPT” the moment it lands, and keep that label attached until the visitor fills in a form. Here's how to set that up with built-in parts, where it stops, and the quicker route.
Step 1: Switch on the Referrer and Page URL variables
- In your web container, click Variables in the left navigation.
- In the Built-In Variables section, make sure Referrer and Page URL are enabled. Google's help docs describe Referrer as “the full referrer URL for the current page”.
That one variable is most of the detection. A click from ChatGPT on the web arrives with a referrer of https://chatgpt.com/ (older links may show chat.openai.com).
Step 2: Turn the referrer into a clean “AI source” label
- In the User-Defined Variables section, click New and choose the RegEx Table type.
- Set the input variable to
{{Referrer}}. - Add a row with Pattern
chatgpt\.com|chat\.openai\.comand OutputChatGPT. Set a default value such asnone. - Open the advanced settings and untick Full Matches Only. The referrer is a whole URL, so a pattern that only names the host won't match while that box is ticked. Leave Ignore Case on.
Name it something like AI source. You now have a variable that says ChatGPT or none on every page view.
Step 3: Catch the chatgpt.com UTM tag too
ChatGPT adds utm_source=chatgpt.com to many of the links it shows, and the tag survives even when the referrer is stripped. Create a second user-defined variable of type URL with the component set to Query, then add a second RegEx Table (or a trigger condition) that checks whether the query contains utm_source=chatgpt.com. A visit can carry the referrer, the tag, or both, so treat either one as a match.
Step 4: Make the label survive the second page
This is the part most Tag Manager tutorials skip. The referrer only points at ChatGPT on the landing page. As soon as the visitor clicks through to your contact page, the Referrer variable holds your own site's address and the label falls back to none. If your form sits on page two, the form event knows nothing about ChatGPT.
The fix is to store the label when it's first seen. A small Custom HTML tag, fired on page view only when AI source isn't none, can write the value to a first-party cookie; a 1st Party Cookie variable then reads it back on every later page. Use the cookie variable, not the raw referrer, in the tags that fire on form submissions. If you use a consent banner, this cookie needs the same consent as your other analytics cookies.
Step 5: Send it somewhere, then test it
A variable does nothing until a tag uses it. The common choices are to add it as an event parameter on your GA4 lead or form event (then register it as a custom dimension in GA4's Admin so it shows up in reports), or to drop it into a hidden form field so it reaches your CRM with the enquiry. For plain session counts you don't need any of this: GA4 reads the referrer itself, and our GA4 guide covers that side.
To test, click Preview, load your site with ?utm_source=chatgpt.com added to the address, and check the variable values on the page view event. Then go to a second page and confirm the stored value is still there. Publish only when both hold.
What Tag Manager can't see
| Customer journey | What your tags get |
|---|---|
| Clicks a link in ChatGPT on the web | Referrer chatgpt.com, often with the UTM tag |
| Opens your site from the ChatGPT mobile or desktop app | Often an empty referrer; only the UTM tag, when present, identifies it |
| Lands from ChatGPT, submits a form on another page | Nothing, unless you stored the label (Step 4) |
| Declines your cookie banner | Whatever your consent settings allow, usually nothing |
| Reads ChatGPT's answer, then phones you | Nothing. No tag fires on a phone call |
For that last row the only fix is to ask. Add “How did you first hear about us?” to your form and your phone script; our guide to wording that question explains why “first” matters.
Other AI assistants to check
Add one row per assistant to the same RegEx Table: perplexity\.ai, gemini\.google\.com, claude\.ai and copilot\.microsoft\.com, each with its own output. Don't add google.com: clicks from AI Overviews and AI Mode come from Google itself and can't be separated from ordinary search this way. Our free AI referral regex generator gives you the full pattern, and the AI traffic tracking guide lists what each assistant sends.
The one-tag version
Which AI Sent replaces Steps 1 to 5 with a single tag. In your dashboard's Setup, click Connect Google Tag Manager and approve on Google's own screen: we add the tag in a fresh workspace and then give up access. We never publish, so you review the tag and click Submit yourself. Or add it by hand as a Custom HTML tag on All Pages. The script labels ChatGPT and the other assistants, remembers the source across pages, detects form submissions without form triggers, and records the “how did you hear about us?” answer, so each AI lead is marked Confirmed, Declared or Assisted by the evidence behind it. Details are on the Tag Manager integration page.
ChatGPT traffic in Google Tag Manager: common questions
Can Google Tag Manager show me ChatGPT traffic?
Not on its own. Tag Manager has no reports; it passes data to other tools. You can use its Referrer variable and a RegEx Table to label visits from chatgpt.com, then send that label to GA4, a form field or your CRM, where you can count it.
Why does my ChatGPT label disappear on the contact page?
Because the referrer only points at chatgpt.com on the first page of the visit. On every later page the referrer is your own site. Store the label in a first-party cookie on the landing page and read it back with a 1st Party Cookie variable when the form is submitted.
Why isn't my RegEx Table matching chatgpt.com?
Most often because Full Matches Only is ticked in the variable's advanced settings. The Referrer variable holds a full URL, so a pattern that only names the host fails. Untick Full Matches Only, or write the pattern to match the whole URL.
Does Which AI Sent work with Google Tag Manager?
Yes. Click Connect Google Tag Manager in your dashboard's Setup and approve on Google's screen; the tag is added in a fresh workspace for you to review and publish. You can also paste it as a Custom HTML tag that fires on All Pages.
See the leads and sales AI sends you
Track AI visits all the way to the lead or sale, and catch the customers who never click. Launch offer: every Pro feature is free until October 31. No card needed.