Skip to content
Research
Skill

/date-ranges

Allowed date string formats for the GA4 Data API: YYYY-MM-DD, today, yesterday, 7daysAgo, 30daysAgo, and multi-range period comparisons without API errors.

From plugin
google-analytics-mcp
24417 skills

Claude Code

$ npx -y skills add surendranb/google-analytics-mcp --skill date-ranges --agent claude-code

SKILL.md

date-ranges.SKILL.md
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."

GA4 API Date Ranges: Syntax, Offsets & Comparisons

How to specify date ranges in the Google Analytics 4 Data API and structure period-over-period comparisons without triggering syntax or parsing errors.

Supported Date String Formats

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`).

---

Standard Comparison Windows

| 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"` |

---

Structuring Period-Over-Period Comparisons

To compare two non-overlapping timeframes (e.g., week-over-week or month-over-month), execute two separate `get_ga4_data` calls:

Week-Over-Week Example

  • **Current Week (Call 1):** `start_date="7daysAgo"`, `end_date="yesterday"`
  • **Prior Week (Call 2):** `start_date="14daysAgo"`, `end_date="8daysAgo"`

**Delta Calculation:** `((current_value - prior_value) / prior_value) * 100`

Beware of Day-of-Week Seasonality

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.

---

The Intra-Day "Today" Rule

`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.

Read more
@surendranb
Ships withgoogle-analytics-mcp

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:

Stars on GitHub

Momentum

stars in total
244
Star history of surendranb/google-analytics-mcp on GitHub, a chart by star-history.com

Other skills on google-analytics-mcp.

More skills from other plugins.

academic-paper-review

academic-paper-review

Use this skill when the user requests to review, analyze, critique, or summarize academic papers, research articles, preprints,…

deer-flow10d85k
@bytedance@bytedanceInstall Skill
last30days

last30days

Research what people actually say about any topic in the last 30 days. Pulls posts and engagement from Reddit, X, YouTube,…

@mvanhorn@mvanhornInstall Skill

Questions about date-ranges.

Which coding agents can use date-ranges?
date-ranges installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.