date-ranges

date-ranges is a skill for Claude Code from surendranb/google-analytics-mcp. It costs 25 tokens per session (648 once invoked), scanned A, original, MIT.

A guide to writing date ranges for the Google Analytics 4 Data API, including fixed dates, relative dates such as the last seven complete days, and comparisons between periods. The API requires separate requests for each period being compared.

In plain words
What is it for?
Use it when requesting GA4 data for recent days, months, or year-to-date periods, or when building week-over-week and other period-over-period reports.
Why use it?
It avoids invalid date values and incomplete comparisons caused by accidentally including today's partial data. It also clarifies how to compare periods such as this week with last week.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the google-analytics-mcp plugin — 16 skills, 1 MCP server shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/surendranb/google-analytics-mcp/date-ranges
Any agent
npx skills add surendranb/google-analytics-mcp --skill date-ranges
Clone the repo
git clone --depth 1 https://github.com/surendranb/google-analytics-mcp

Made for: Claude Code.

Or install google-analytics-mcp, the plugin that ships this one along with the rest of its 16 skills, 1 MCP server.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for date-ranges

README.md
[![agentmods](https://agentmods.dev/badge/skills/surendranb/google-analytics-mcp/date-ranges.svg)](https://agentmods.dev/skills/surendranb/google-analytics-mcp/date-ranges)
Your own site
<a href="https://agentmods.dev/skills/surendranb/google-analytics-mcp/date-ranges"><img src="https://agentmods.dev/badge/skills/surendranb/google-analytics-mcp/date-ranges.svg" alt="Measured on agentmods" height="20"></a>
Per session 25 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 648 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00025 $0.00648
Opus 5 $0.00013 $0.00324
Sonnet 5 $0.00005 $0.00130
Haiku 4.5 $0.00003 $0.00065

Measured 6d ago against content hash 55a83832d4ae, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

date-ranges scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/date-ranges/SKILL.md · 82 lines

How it starts

The opening of the file, as written. The whole thing — 82 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Date Ranges

How to specify date ranges in get_ga4_data and how to structure period-over-period comparisons.

Valid formats

date_range_start / date_range_end accept:
  "YYYY-MM-DD"   — absolute date, e.g. "2024-01-15"
  "today"        — current day (partial — use carefully)
  "yesterday"    — last complete day
  "NdaysAgo"     — N days back from today, e.g. "7daysAgo", "30daysAgo", "90daysAgo"

NdaysAgo excludes today. 7daysAgo to yesterday = last 7 complete days.

Common windows

Window start end
Last 7 days 7daysAgo yesterday
Last 28 days 28daysAgo yesterday
Last 90 days 90daysAgo yesterday
This month YYYY-MM-01 today
Last month YYYY-MM-01 (prior) YYYY-MM-last-day (prior)
Year to date YYYY-01-01 yesterday

Period-over-period comparison

The GA4 Data API does not support multi-period in a single call. Run two separate get_ga4_data calls, then compare the results.

Example: week-over-week

Call 1 — this week:

date_range_start: "7daysAgo"
date_range_end:   "yesterday"

Call 2 — last week:

date_range_start: "14daysAgo"
date_range_end:   "8daysAgo"

Example: year-over-year for July

Call 1 — this year:

date_range_start: "2025-07-01"
date_range_end:   "2025-07-31"

Call 2 — last year:

date_range_start: "2024-07-01"
date_range_end:   "2024-07-31"

Then compute the delta: (current - prior) / prior * 100 for each metric.

Partial-day reads

today includes only the hours elapsed so far. Comparing today to yesterday is misleading — yesterday is a full day, today is partial.

For intra-day analysis, use today for both start and end and note the IST hours covered in your interpretation.

Common mistakes

  • "last7days" is NOT valid — use "7daysAgo"
  • "last-week" is NOT valid — use absolute dates or NdaysAgo
  • Do not use date_range_end: "today" when comparing to a prior complete period
  • "0daysAgo" = today (same as "today")

Read the full file on GitHub · 82 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 82 lines · 25 tokens per session scan A 55a83832d4ae

Subscribe to this mod's changes

date-ranges is a skill published in the GitHub repository surendranb/google-analytics-mcp (241 stars, last pushed 4d ago), licensed MIT. It adds 25 tokens to every session and 648 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories