What it does
AI assistants now cite and link to websites, and those visits land in GA4 as ordinary referrals, scattered between chatgpt.com, perplexity.ai and a dozen others. There is no default channel for them, so most teams cannot say whether the traffic is growing, which pages it lands on, or whether those visitors convert.
The agent filters GA4 by session source with one regular expression, adds up the assistants, and tracks the total week by week. You see the trend, the share of all sessions, and the pages assistants send people to, which is a fair hint of what they quote you on.
How it works
1Filter sessions by AI source
Call
runReportfor the last 7 full days withdimensions: [{ name: "sessionSource" }], the metricssessions,engagedSessionsandkeyEvents, and adimensionFilteronsessionSourcewithmatchType: "PARTIAL_REGEXP",caseSensitive: falseand the patternchatgpt|openai|perplexity|gemini\.google|claude\.ai|copilot|deepseek.2Get the denominator
Run the same date range with no filter and no dimension for total sessions, so the card can show the AI share.
3See where they land
Repeat the filtered report with
landingPagePlusQueryStringas the dimension and keep the top 10 pages by sessions, with key events for each.- 4
4Build the trend
On the first run, backfill with one filtered report over the last 56 days with the
isoYearIsoWeekdimension. Afterwards, compare with the stored weeks. Group sources into assistants (allchatgpt.comandchat.openai.comrows count as ChatGPT). - 5
5Post the tile
AI assistant sessions is the headline with 8 weeks of history. Share of sessions and key events go in the glance; sessions by assistant and the landing pages open with the card.
Post it to the board
With
BRIEFKIN_TOKENset, the agent sends the result as one card that updates in place every run. Without it, you get the report in the chat.
Install and run it
Pick your agent, where the data comes from and how to schedule it; the commands below follow.
Install the skill
One command. It puts the SKILL.md in ~/.claude/skills and in ~/.agents/skills, which Codex, Cursor, Gemini CLI, Copilot CLI and OpenCode read too.
shell
curl -fsSL https://briefkin.dev/skills/google-analytics-ai-assistant-traffic/install | shRun it
Ask Claude Code:
prompt
Run the google-analytics-ai-assistant-traffic skillOr paste the prompt instead of installing:
prompt
Using the GA4 Data API (runReport), count last week's sessions, engaged sessions and key events whose sessionSource matches the case-insensitive regular expression chatgpt|openai|perplexity|gemini\.google|claude\.ai|copilot|deepseek (PARTIAL_REGEXP), grouped by sessionSource and then by assistant. Get total sessions for the same week without the filter and work out the AI share. Show the top 10 landing pages (landingPagePlusQueryString) for these sessions with key events. Compare with the week before, and if this is the first run, give me the last 8 weeks using isoYearIsoWeek.Put it on a schedule
Mondays at 8:00, from cron on any machine where Claude Code is signed in:
crontab
0 8 * * 1 claude -p "Run the google-analytics-ai-assistant-traffic skill"Add it with
crontab -e. A laptop asleep at that time runs it when it wakes if you use launchd or Task Scheduler instead; GitHub Actions works for the API route.Send it to your board
Connect Briefkin once with
curl -fsSL https://briefkin.dev/install | shand every run lands on your board as a stat tile. How setup works
View the SKILL.mdRaw file
SKILL.md---
name: google-analytics-ai-assistant-traffic
description: "Every Monday: last week's GA4 sessions from ChatGPT, Perplexity, Gemini, Claude and Copilot, their share of all traffic, and the pages they land on. Use when the user asks for this, or when it runs on a schedule."
---
# GA4 AI assistant traffic report
Every Monday: last week's GA4 sessions from ChatGPT, Perplexity, Gemini, Claude and Copilot, their share of all traffic, and the pages they land on.
AI assistants now cite and link to websites, and those visits land in GA4 as ordinary referrals, scattered between chatgpt.com, perplexity.ai and a dozen others. There is no default channel for them, so most teams cannot say whether the traffic is growing, which pages it lands on, or whether those visitors convert.
The agent filters GA4 by session source with one regular expression, adds up the assistants, and tracks the total week by week. You see the trend, the share of all sessions, and the pages assistants send people to, which is a fair hint of what they quote you on.
## Two ways to get the data
Use the API or MCP route when you have an MCP server, a CLI or an API token for the app. Otherwise, if you can drive a browser the user is signed in to (Claude in Chrome, a Playwright or Chrome DevTools MCP server), use the browser route. Say which one you used.
## Route A: API or MCP server
### What you need
- Viewer access to the GA4 property and its numeric property ID.
- Google's open-source Google Analytics MCP server (`analytics-mcp`, read-only scope), or a service account with the Analytics Data API enabled and `GOOGLE_APPLICATION_CREDENTIALS` set.
If something is missing, say what and stop; do not invent numbers.
### Steps
1. **Filter sessions by AI source** (Google Analytics): Call `runReport` for the last 7 full days with `dimensions: [{ name: "sessionSource" }]`, the metrics `sessions`, `engagedSessions` and `keyEvents`, and a `dimensionFilter` on `sessionSource` with `matchType: "PARTIAL_REGEXP"`, `caseSensitive: false` and the pattern `chatgpt|openai|perplexity|gemini\.google|claude\.ai|copilot|deepseek`.
2. **Get the denominator** (Google Analytics): Run the same date range with no filter and no dimension for total sessions, so the card can show the AI share.
3. **See where they land** (Google Analytics): Repeat the filtered report with `landingPagePlusQueryString` as the dimension and keep the top 10 pages by sessions, with key events for each.
4. **Build the trend**: On the first run, backfill with one filtered report over the last 56 days with the `isoYearIsoWeek` dimension. Afterwards, compare with the stored weeks. Group sources into assistants (all `chatgpt.com` and `chat.openai.com` rows count as ChatGPT).
5. **Post the tile**: AI assistant sessions is the headline with 8 weeks of history. Share of sessions and key events go in the glance; sessions by assistant and the landing pages open with the card.
## Route B: the browser
### What you need
- Signed in to Google with at least Viewer access to the GA4 property.
If something is missing, say what and stop; do not invent numbers.
### Steps
Start at https://analytics.google.com/analytics/web/. The user is signed in already; never type passwords or codes, and ask if a sign-in page appears.
1. **Open an exploration on the right property**: The URL opens the property you used last; switch with the property picker at the top left. Go to **Explore** and create a blank (free form) exploration, because the standard report's search box only does a contains match, not the pattern this report needs.
2. **Set dates, dimension and filter**: Date range: the last 7 full days (last Monday through Sunday), with **Compare** to the previous period. Rows: `Session source`. Values: `Sessions`, `Engaged sessions`, `Key events`. Add a filter: Session source **matches regex** `chatgpt|openai|perplexity|gemini\.google|claude\.ai|copilot|deepseek`.
3. **Get the denominator**: Open **Reports > Acquisition > Traffic acquisition** with the same date range and read total sessions from the totals row, so the AI share can be worked out.
4. **See where they land**: Back in the exploration, add a second tab with `Landing page + query string` as the row dimension and the same filter; keep the top 10 pages by sessions with their key events.
5. **Build the trend**: On the first run, set the date range to the last 8 weeks and add a tab with `Week` as the row dimension and the same filter, to get one total per week. Group sources into assistants (`chatgpt.com` and `chat.openai.com` are both ChatGPT).
Note: Explorations can be sampled on large properties; the sampling icon at the top right says so. The last day or two of data can still be processing, so a Monday run should end its range on Sunday and accept small revisions. Explorations are kept per user, so save this one and reuse it next week.
## The report
- **AI assistant sessions** last week, with an 8-week trend.
- **Share** of all sessions, and **key events** from those sessions.
- **By assistant**: ChatGPT, Perplexity, Gemini, Copilot, Claude and others.
- **Top landing pages** for AI traffic.
## Post it to Briefkin
When `BRIEFKIN_TOKEN` is set, or `~/.config/briefkin/env` exists (the installer from https://briefkin.dev/docs writes it), also send the result to the user's Briefkin board as one card. Keep the `item_key` the same on every run so the card updates in place, use a new `event_id` per run, and put today's real numbers in place of the example ones. If the request fails, say so once and carry on.
```bash
[ -n "${BRIEFKIN_TOKEN:-}" ] || . ~/.config/briefkin/env
curl -sS -X POST "${BRIEFKIN_URL:-https://briefkin.dev}/v1/events" \
-H "authorization: Bearer $BRIEFKIN_TOKEN" \
-H "content-type: application/json" \
-d @- <<'JSON'
{
"v": 1,
"event_id": "google-analytics-ai-assistant-traffic/<date of this run, e.g. 2026-10-16>",
"item_key": "google-analytics-ai-assistant-traffic",
"project": "example.com",
"source": "GA4 AI assistant traffic report skill",
"kind": "metric",
"title": "AI assistant sessions up 14% to 1,284",
"metric": {
"label": "AI assistant sessions",
"value": 1284,
"better": "higher",
"period_start": "<start of the period, ISO 8601>",
"period_end": "<end of the period, ISO 8601>"
},
"glance": {
"type": "Grid",
"props": {
"columns": 3
},
"children": [
{
"type": "Stat",
"props": {
"label": "Share of sessions",
"value": 2.9,
"unit": "%",
"delta": 12
}
},
{
"type": "Stat",
"props": {
"label": "Key events",
"value": 96,
"delta": 20
}
},
{
"type": "Stat",
"props": {
"label": "From ChatGPT",
"value": 842,
"delta": 11
}
}
]
},
"widget": [
{
"type": "Bars",
"props": {
"items": [
{
"label": "ChatGPT",
"value": 842
},
{
"label": "Perplexity",
"value": 196
},
{
"label": "Gemini",
"value": 118
},
{
"label": "Copilot",
"value": 74
},
{
"label": "Claude",
"value": 54
}
],
"unit": "sessions"
}
},
{
"type": "Table",
"props": {
"columns": [
"Landing page",
"Sessions",
"Key events"
],
"align": [
"left",
"right",
"right"
],
"rows": [
[
"/templates/invoice",
318,
31
],
[
"/blog/net-30-payment-terms",
204,
9
],
[
"/pricing",
161,
28
],
[
"/",
122,
11
]
]
}
}
],
"size": "md"
}
JSON
```
Widgets come from the Briefkin catalog (https://briefkin.dev/v1/catalog). Without a token, just give the user the report.
Set `period_start` and `period_end` to the window the number covers: the tile names it from them ("Last 7 days", "Today", "This month"). For a count right now (open items, a balance), send `"period_label": ""` so no period shows; for another name, send it as `period_label` (at most 24 characters).
## Run it on a schedule
Suggested: Mondays at 8:00 (`0 8 * * 1`). From cron, with the agent signed in on that machine:
```bash
0 8 * * 1 claude -p "Run the google-analytics-ai-assistant-traffic skill"
# Codex: codex exec, Gemini CLI: gemini -p, Copilot CLI: copilot -p, OpenCode: opencode run
```
Or use the agent's own scheduler (Claude Code routines, Codex automations, Claude or ChatGPT scheduled tasks): https://briefkin.dev/skills/google-analytics-ai-assistant-traffic#schedule
Source: https://briefkin.dev/skills/google-analytics-ai-assistant-traffic
What your agent needs
Viewer access to the GA4 property and its numeric property ID.
Google's open-source Google Analytics MCP server (
analytics-mcp, read-only scope), or a service account with the Analytics Data API enabled andGOOGLE_APPLICATION_CREDENTIALSset.
Connecting Google Analytics
- Google Analytics MCP server, Google's own open-source server (
analytics-mcpon PyPI, source). It runs locally withpipx run analytics-mcp, offersrun_report,run_realtime_reportandget_account_summaries, and Google labels it experimental. - Data API with a service account. Enable the Google Analytics Data API in a Google Cloud project, create a service account, add its email as a Viewer on the GA4 property, and point
GOOGLE_APPLICATION_CREDENTIALSat its JSON key. The skill also readsGA4_PROPERTY_ID. - Your own Google login.
gcloud auth application-default login --scopes https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform --client-id-file=client.jsongives the MCP server or a script your user's access without a key file.
Request only analytics.readonly and keep the service account at Viewer: none of these reports needs Editor.
Questions
Does this catch all AI traffic?
No. It catches visits that arrive with a recognizable referrer or utm_source, which covers most clicks from ChatGPT, Perplexity and Gemini. Apps that strip the referrer, and people who copy a URL into a new tab, show up as Direct. Read the number as a floor and watch its trend.
Should I add my own assistants to the pattern?
Yes, when a new one shows up. Once a month, look at the top 100 session sources in GA4 for names you do not recognize, and add them to the regular expression in the skill. Keep the old ones so the history stays comparable.
Do I need Briefkin to use the GA4 AI assistant traffic report skill?
No. The skill runs with your own agent and gives you the report in the chat. With a Briefkin token set, each run also posts it to your board as a stat tile, so you can glance at it instead of asking again.
Which agents can run it?
Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot CLI, OpenCode, Windsurf and Amp all read SKILL.md files. The install command puts it in ~/.claude/skills and ~/.agents/skills, where they look. ChatGPT, the Claude app and Grok take the prompt instead. Pick your agent under "Install and run it" and the commands change to match.
Can it work without an API or MCP server, from my browser?
Yes. Switch the data source to "Your browser" and the steps change to the Google Analytics pages themselves: the agent opens analytics.google.com/analytics/web in a browser you are signed in to and reads the numbers off the page. Claude Code, Codex, Cursor, Claude app and ChatGPT can drive a browser out of the box; Gemini CLI, Copilot CLI and OpenCode need a Playwright or Chrome DevTools MCP server first. It is slower than the API and needs you signed in, so it suits a report you run by hand or from a scheduler on your own computer.