ai-referral-analysis
How to track and measure traffic from ChatGPT, Claude, Perplexity, and Gemini in GA4. Exact dimension filters, regex patterns,β¦
Allowed date string formats for the GA4 Data API: YYYY-MM-DD, today, yesterday, 7daysAgo, 30daysAgo, and multi-range period comparisons without API errors.
Claude Code
$ npx -y skills add surendranb/google-analytics-mcp --skill date-ranges --agent claude-code
Codex
$ npx skills add surendranb/google-analytics-mcp --skill date-ranges -a codex -y
Cursor
$ npx skills add surendranb/google-analytics-mcp --skill date-ranges -a cursor -y
Gemini CLI
$ npx skills add surendranb/google-analytics-mcp --skill date-ranges -a gemini-cli -y
GitHub Copilot
$ npx skills add surendranb/google-analytics-mcp --skill date-ranges -a github-copilot -y
OpenCode
$ npx skills add surendranb/google-analytics-mcp --skill date-ranges -a opencode -y
Windsurf
$ npx skills add surendranb/google-analytics-mcp --skill date-ranges -a windsurf -y
name: date-ranges titleTag: "GA4 API Date Ranges: Syntax, Offsets & Comparison" description: "Allowed date string formats for the GA4 Data API: YYYY-MM-DD, today, yesterday, 7daysAgo, 30daysAgo, and multi-range period comparisons without API errors."
How to specify date ranges in the Google Analytics 4 Data API and structure period-over-period comparisons without triggering syntax or parsing errors.
The GA4 Data API accepts four formats for start and end dates:
| Format String | Description | Example | |---|---|---| | `YYYY-MM-DD` | Exact calendar date | `"2026-10-15"` | | `today` | Current calendar day (partial data) | `"today"` | | `yesterday` | Most recent complete calendar day | `"yesterday"` | | `NdaysAgo` | Relative offset from current day | `"7daysAgo"`, `"30daysAgo"`, `"90daysAgo"` |
> β οΈ **Common Syntax Errors:** Strings like `"last7days"`, `"last-week"`, or `"lastMonth"` are **invalid** and will cause an API parse error. Always use `NdaysAgo` or exact ISO dates (`YYYY-MM-DD`).
---
| Analysis Window | Recommended Start Date | Recommended End Date | |---|---|---| | **Last 7 Complete Days** | `"7daysAgo"` | `"yesterday"` | | **Last 28 Complete Days** | `"28daysAgo"` | `"yesterday"` | | **Last 90 Complete Days** | `"90daysAgo"` | `"yesterday"` | | **Current Month to Date** | `"YYYY-MM-01"` | `"today"` | | **Full Prior Month** | Prior month 1st | Prior month last day | | **Year to Date (YTD)** | `"YYYY-01-01"` | `"yesterday"` |
---
To compare two non-overlapping timeframes (e.g., week-over-week or month-over-month), execute two separate `get_ga4_data` calls:
**Delta Calculation:** `((current_value - prior_value) / prior_value) * 100`
Never compare an incomplete current week against a full prior week, and avoid comparing weekends to weekdays directly. Traffic on Mondays often differs substantially from Saturdays. Always compare identical day-of-week groupings.
---
`today` contains partial-day data up to the current hour. Comparing `today` to `yesterday` directly will always show an artificial traffic drop because `yesterday` represents 24 hours of data while `today` covers only elapsed hours. For daily trend tracking, use `"yesterday"` as your end boundary.
Model Context Protocol (MCP) server for Google Analytics 4: real-time query exploration, schema discovery, metric aggregation, and audience insights for AI agents. π Live Documentation & Web Portal:
How to track and measure traffic from ChatGPT, Claude, Perplexity, and Gemini in GA4. Exact dimension filters, regex patterns,β¦
Why session, user, and event metrics never match in GA4. Rules for pairing dimensions and metrics across user-scoped,β¦
Detect and filter automated bot spikes in Google Analytics 4. Patterns for datacenter ASN spikes, zero-second sessions, andβ¦
How GA4 Default Channel Groups work, how to audit channel performance, and how to spot traffic falling into Unassigned or Directβ¦
Exact API field names for GA4 Data API queries. Avoid 400 errors from Universal Analytics names like ga:sessions or pageviews byβ¦
Which dimensions and metrics can be queried together in GA4 without triggering incompatible scope errors. Matrix of user,β¦
Use this skill when the user requests to review, analyze, critique, or summarize academic papers, research articles, preprints,β¦
Research what people actually say about any topic in the last 30 days. Pulls posts and engagement from Reddit, X, YouTube,β¦
Estimates intracellular metabolic fluxes from steady-state carbon-13 isotope-tracing measurements using validated atom maps,β¦
Search literature across sources, verify or manage citations, and build MeSH strategies or citation-impact audits. Use forβ¦