Agent skill

Google Analytics 4 Analysis

by LichAmnesia in LichAmnesia/lich-skills

Pulls Google Analytics 4 data through the Data API with TypeScript scripts and turns it into a daily SEO report or prioritized traffic and bounce-rate recommendations.

MITAuto-check: notesMarketing & SEO

Install Google Analytics 4 Analysis

skills CLI
$ npx skills add LichAmnesia/lich-skills --skill google-analytics -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install LichAmnesia/lich-skills google-analytics --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/LichAmnesia/lich-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/google-analytics .claude/skills/google-analytics && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
google-analytics
GitHub stars
234
Token cost
~2k tokens
SKILL.md length
785 words
Files
8 (incl. scripts)
Skills in repo
11
Repo updated
First seen
Licence
MIT

At a glance

Pulls Google Analytics 4 data through the Data API with TypeScript scripts and turns it into a daily SEO report or prioritized traffic and bounce-rate recommendations.

  • Works in 2 steps: Credentials (env vars) → Install the one dependency
  • Getting a daily SEO report for a GA4 property
  • SKILL.md covers When to use, When NOT to use, Setup and Scripts, plus 4 more sections
  • Runs TypeScript scripts from its folder; calls bun, npx and npm; needs GOOGLE_APPLICATION_CREDENTIALS

What it does

The skill reads GA4 aggregates through the official Data API client using TypeScript scripts run with Bun or `npx tsx`. Its default, `daily-report.ts`, takes one property and produces an organic-search report with no setup beyond credentials, and can write JSON to a file. Other requests it handles include reviewing the last 30 days, finding top traffic sources and high-bounce pages, comparing months and diagnosing why mobile converts worse than desktop.

Setup needs a numeric `GOOGLE_ANALYTICS_PROPERTY_ID` and a `GOOGLE_APPLICATION_CREDENTIALS` path to a service account key, with the account given only the Viewer role, plus one dependency installed with `bun install` or npm. The key and `.env` must never be committed. The skill is read-only: it does not do real-time analytics, change GA configuration, audiences or events, or return individual-user data.

When your agent uses it

  • Getting a daily SEO report for a GA4 property
  • Finding top traffic sources, organic landing pages and high-bounce pages
  • Comparing this month with last month
  • Diagnosing why mobile conversion is lower than desktop

Example prompts

  • “Give me today's SEO report for GA4 property 123456789.”
  • “Review our Google Analytics performance for the last 30 days and rank the fixes.”
  • “Which landing pages have the highest bounce rates this month?”

Requirements

  • A GA4 property ID
  • A Google service account key with Viewer access to the property
  • Bun, or Node.js with npx tsx

Workflow steps

2 steps, taken from the step headings in SKILL.md.

  1. Credentials (env vars)
  2. Install the one dependency

What it can do on your machine

Read from SKILL.md and the folder at commit ebbc355. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 4 files in scripts/ (TypeScript), which the agent can run.

    Shell commands in SKILL.md call:

    • bun
    • npx
    • npm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • bun.sh

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • GOOGLE_APPLICATION_CREDENTIALS

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Google Analytics 4 Analysis loads about 2k tokens when it runs. Until then it costs about 83 tokens; SKILL.md has 785 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~83
When it runs · the whole SKILL.md, loaded when a task matches
~2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteMentions a .env fileSKILL.md:35
    r copy [`.env.example`](.env.example) → `.env` (Bun auto-loads `.env`; under `tsx`, export the vars instead). Full servi
  • NoteMentions a .env fileSKILL.md:37
    **Never commit the JSON key or `.env`.** Store the key outside the repo; grant the service account only the **Viewer** r
  • NoteMentions a .env fileSKILL.md:103
    ort` the env vars, since tsx won't read `.env`).
  • NoteMentions a .env fileSKILL.md:142
    - Credentials come from env vars / `.env` only — never hardcoded.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from LichAmnesia/lich-skills at commit ebbc355, republished under its MIT licence (© LichAmnesia). 785 words, ~2,025 tokens.

Download SKILL.mdSave it as .claude/skills/google-analytics/SKILL.md (or your agent's skills folder). This skill also uses 7 other files; get the full folder from GitHub.
name
google-analytics
description
Analyze Google Analytics 4 data — review website performance, identify traffic patterns, diagnose high-bounce pages, compare time periods, and suggest data-driven improvements. Use when the user asks about analytics, website metrics, traffic analysis, conversion rates, user behavior, or performance optimization.

Google Analytics 4 Analysis

Pull GA4 data via the Data API and turn it into actionable, prioritized recommendations. Scripts are TypeScript (run with Bun or npx tsx).

When to use

  • "Give me a daily SEO report for this property" → daily-report.ts (the out-of-the-box default)
  • "Review our Google Analytics performance for the last 30 days"
  • "How is organic search doing?" / "Which landing pages pull organic traffic?"
  • "What are our top traffic sources?"
  • "Which pages have the highest bounce rates?"
  • "Compare this month vs last month"
  • "Why is mobile converting worse than desktop?"

When NOT to use

  • Real-time / streaming analytics — this uses the batch reporting API
  • Editing GA config, audiences, or events — read-only by design
  • Anything needing PII / individual-user data — GA4 returns aggregates only

Setup

1. Credentials (env vars)
bash
export GOOGLE_ANALYTICS_PROPERTY_ID="YOUR_PROPERTY_ID_HERE"   # numeric, not the G- id
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"

Or copy .env.example → .env (Bun auto-loads .env; under tsx, export the vars instead). Full service-account walkthrough is inside .env.example.

Never commit the JSON key or .env. Store the key outside the repo; grant the service account only the Viewer role on the GA4 property.

2. Install the one dependency
bash
cd skills/google-analytics/scripts
bun install            # or: npm install

The only runtime dep is @google-analytics/data (official Google client, fully typed).

Scripts

daily-report.ts — SEO daily report (out-of-the-box default) ⭐

Point it at one property and get a complete, opinionated organic-search report — zero config beyond credentials. This is the SEO-expert default template.

bash
bun run daily-report.ts --property 123456789      # one property → one report
bun run daily-report.ts                            # uses GOOGLE_ANALYTICS_PROPERTY_ID
bun run daily-report.ts --format json --output today.json

Default template (in order): Organic KPIs (rolling 28d vs prior 28d — the Search-Console 4-week-block convention that removes day-of-week skew) · daily anomaly check (yesterday vs same weekday last week, flags drops ≥ 25%) · organic trend sparkline · top organic landing pages (the SEO money view) · by search engine · by country · by device (mobile-first) · auto-generated prioritized recommendations. Everything is filtered to sessionDefaultChannelGroup = "Organic Search".

Flags: --property <id>, --days <n> (default 28), --channel <name> (default "Organic Search"), --anomaly-threshold <pct> (default 25), --format md|json (default md), --output FILE, --help. Writes seo-daily-<date>.md by default.

It auto-detects whether the property uses GA4's conversions or the newer keyEvents metric, and any single failing sub-query degrades gracefully instead of aborting the report.

GA4 limitation: GA4 has no keyword / impression / CTR / average-position data — that lives in Google Search Console (a different API). This report covers the organic behavior GA4 owns; pair with GSC for the query side.

ga-client.ts — raw report query

Thin wrapper over runReport. Any metrics × dimensions combo.

bash
# Last 30 days of sessions + users (JSON)
bun run ga-client.ts --days 30 --metrics sessions,users

# Top pages by views, table output
bun run ga-client.ts --days 7 --metrics screenPageViews \
  --dimensions pagePath --order-by screenPageViews --limit 20 --format table

# Specific window, filtered by country
bun run ga-client.ts --start 2026-01-01 --end 2026-01-31 \
  --metrics sessions,bounceRate --dimensions country --filter "country:United States"

Flags: --days N | --start --end (YYYY-MM-DD or NdaysAgo/yesterday), --metrics (required, comma-sep), --dimensions, --limit (default 10), --order-by (prefix - desc / + asc), --filter "field:value", --format json|table, --output FILE.

analyze.ts — higher-level analysis + recommendations

Pre-built analyses that return metrics plus prioritized recommendations.

bash
bun run analyze.ts --analysis-type seo      --days 28   # organic-only KPIs + top landing pages
bun run analyze.ts --analysis-type overview --days 30   # current vs previous period
bun run analyze.ts --analysis-type sources  --days 30   # traffic sources + optimizations
bun run analyze.ts --analysis-type content  --days 30   # high-bounce pages + diagnosis (all channels)
bun run analyze.ts --analysis-type devices  --days 30   # mobile vs desktop gap (all channels)

--output FILE writes JSON to disk instead of stdout. --channel <name> overrides the organic channel group for the seo cut.

Which report do I actually need? For SEO, reach for daily-report.ts first and --analysis-type seo for a quick organic snapshot. overview / sources are useful general cuts. content and devices are all-channel (not organic-only) and content keys off bounceRate (a de-emphasized GA4 metric) — keep them for general GA use, but for SEO the daily report's organic-filtered device/landing cuts supersede them.

No Bun? Swap bun run X.ts → npx tsx X.ts everywhere (and export the env vars, since tsx won't read .env).

Show full SKILL.md (276 more words)Show less

Workflow

When the user asks an analytics question:

  1. Pick the script — a specific metric/dimension question → ga-client.ts; a "how are we doing / what should we fix" question → analyze.ts.
  2. Run it, capture the JSON.
  3. Interpret — surface trends, anomalies, bottlenecks, and conversion opportunities.
  4. Recommend — concrete actions, each with priority (HIGH/MEDIUM/LOW) and expected impact. Lead with the single highest-leverage fix.

See EXAMPLES.md for end-to-end question → command → analysis patterns, and REFERENCE.md for the full metric/dimension catalog.

Run it every day (automation)

The report is a single self-contained command, so any scheduler works. Two options:

Plain cron — write a dated report to a folder each morning (GA4 finalizes "yesterday" within ~24h, so an early-AM run is safe):

bash
# crontab -e  (8:00 every day) — adjust the absolute paths
0 8 * * * cd /path/to/skills/google-analytics/scripts && \
  GOOGLE_ANALYTICS_PROPERTY_ID=123456789 \
  GOOGLE_APPLICATION_CREDENTIALS=/secure/sa.json \
  /usr/local/bin/bun run daily-report.ts --output "/reports/seo-$(date +\%F).md"

Claude Code /schedule — schedule an agent that runs daily-report.ts, then reads the Markdown and messages you the 2-3 highest-priority recommendations (turns the raw report into a daily briefing). Ask: "schedule a daily 8am SEO report for property 123456789 and summarize the HIGH recommendations."

Either way: one property in → one report out, every day.

Troubleshooting

  • Auth error — GOOGLE_APPLICATION_CREDENTIALS points at a valid JSON key, the service account has Viewer on the property, and GOOGLE_ANALYTICS_PROPERTY_ID is the numeric property ID (not the G-XXXX measurement ID).
  • No data — verify the property ID, that the date range has data, and that access was granted in GA4. Use yesterday (not today) — today's data is incomplete.
  • Module not found — run bun install (or npm install) inside scripts/.

Security & privacy

  • Credentials come from env vars / .env only — never hardcoded.
  • The service-account JSON lives outside version control; rotate keys periodically.
  • Least privilege: Viewer role only.
  • Accesses aggregated data only — no PII, no persistence, no third-party sharing, no config writes.

© LichAmnesia, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 7 other files (scripts) in skills/google-analytics of LichAmnesia/lich-skills.

  • SKILL.md
  • .env.example
  • EXAMPLES.md
  • REFERENCE.md
  • scripts/analyze.ts
  • scripts/daily-report.ts
  • scripts/ga-client.ts
  • scripts/package.json

Open the folder on GitHubat commit ebbc355

Compare with similar skills

Google Analytics 4 Analysis next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Google Analytics 4 Analysis compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Google Analytics 4 Analysis this skillLichAmnesia/lich-skills234—~2kAutomated safety check: NotesMIT
Google SEO APIsAgriciDaniel/claude-seo18k1 repos~4.2kAutomated safety check: PassMIT
AnalyticsNexus-JPF/note-companion8696 repos~2.2kAutomated safety check: PassMIT
GEO Monthly Delta Reportzubair-trabzada/geo-seo-claude11k—~2.4kAutomated safety check: NotesMIT
Analytics Trackingborghei/Claude-Skills874—~5.7kAutomated safety check: PassMIT
Paid Social BriefOotto-AI/claude-content-skills101—~831Automated safety check: PassMIT

Similar skills

  • Google SEO APIs

    AgriciDaniel/claude-seo

    Pulls real Google data for SEO work: Search Console, PageSpeed Insights, CrUX field data, the Indexing API and GA4 organic traffic, through /seo google commands.

    18k GitHub starsUsed in 1 repo~4.2k tokens
    Marketing & SEOAuto-check passed
  • Analytics

    Nexus-JPF/note-companion

    When the user wants to set up, improve, or audit analytics tracking and measurement.

    869 GitHub starsUsed in 6 repos~2.2k tokens
    Marketing & SEOAuto-check passed
  • GEO Monthly Delta Report

    zubair-trabzada/geo-seo-claude

    Compares a baseline and a current GEO audit for a client, calculates score changes and action item progress, and writes a monthly progress report.

    11k GitHub stars~2.4k tokensUpdated yesterday
    Marketing & SEOAuto-check: notes
  • Analytics Tracking

    borghei/Claude-Skills

    End-to-end analytics implementation for web and SaaS: GA4, Google Tag Manager, event taxonomy, conversion tracking, and UTM strategy.

    874 GitHub stars~5.7k tokensUpdated today
    Marketing & SEOAuto-check passed
  • Paid Social Brief

    Ootto-AI/claude-content-skills

    A skill your agent uses when an approved social campaign needs a media-ready brief for paid distribution, creative testing, and measurement.

    101 GitHub stars~831 tokensUpdated 1 mo ago
    Marketing & SEOAuto-check passed
  • Soku CLI

    About-Intelligence/soku-cli

    Guides an agent through the soku command line tool for ads, GA4 and PostHog data reads, ads writes, SEO hosting, automations, files and skill management.

    304 GitHub stars~2.4k tokensUpdated 2 days ago
    Marketing & SEOAuto-check passed

More from LichAmnesia/lich-skills

All 11 skills in this repo
  • Nano Banana Image Generator

    LichAmnesia/lich-skills

    Generates or edits PNG images with Google's Nano Banana 2 model through a small script, with a choice of 512, 1K, 2K or 4K output.

    234 GitHub stars~1.1k tokensUpdated 3 mo ago
    Auto-check: notes
  • Spec-Driven Development v2

    LichAmnesia/lich-skills

    Organizes long-running agent work into a Project, Sprint and Task hierarchy with per-task state files, isolated worktrees, review loops and script-checked rules.

    234 GitHub stars~3.1k tokensUpdated 3 mo ago
    Auto-check passed
  • Tavily Web Search

    LichAmnesia/lich-skills

    Runs headless web searches and single-page extraction through the Tavily API from a Python script, returning cited, summarized results without a browser.

    234 GitHub stars~1k tokensUpdated 3 mo ago
    Auto-check: notes
  • Build Until Pass Loop

    LichAmnesia/lich-skills

    Drives a failing build, typecheck, lint or test command to a passing exit code through small, one-fix-at-a-time rounds, stopping at a hard attempt cap instead of looping forever.

    234 GitHub stars~2.8k tokensUpdated 3 mo ago
    Auto-check passed
  • Hypothesis-Driven Debugging

    LichAmnesia/lich-skills

    Replaces trial-and-error fixing with an observe, hypothesize, experiment and conclude loop kept in DEBUG.md, where no fix is allowed before evidence supports a cause.

    234 GitHub stars~2.5k tokensUpdated 3 mo ago
    Auto-check passed
  • Spec-Driven Development

    LichAmnesia/lich-skills

    Runs a gated Spec, Plan, Build, Test, Review, Ship workflow so non-trivial changes are specified, verified and reviewed before they ship, with a named artifact per phase.

    234 GitHub stars~3.5k tokensUpdated 3 mo ago
    Auto-check passed

Questions about Google Analytics 4 Analysis

What does Google Analytics 4 Analysis do?

Pulls Google Analytics 4 data through the Data API with TypeScript scripts and turns it into a daily SEO report or prioritized traffic and bounce-rate recommendations. The skill reads GA4 aggregates through the official Data API client using TypeScript scripts run with Bun or `npx tsx`.ts`, takes one property and produces an organic-search report with no setup beyond credentials, and can write JSON to a file.

When should I use Google Analytics 4 Analysis?

Google Analytics 4 Analysis fits situations like: getting a daily SEO report for a GA4 property; finding top traffic sources, organic landing pages and high-bounce pages; comparing this month with last month; diagnosing why mobile conversion is lower than desktop.

How do I install Google Analytics 4 Analysis in Claude Code?

Run `npx skills add LichAmnesia/lich-skills --skill google-analytics -a claude-code`. Or copy the skill folder (skills/google-analytics in LichAmnesia/lich-skills) into .claude/skills/google-analytics in your project. Claude Code loads it when a task matches its description.

How do I install Google Analytics 4 Analysis in Codex?

Run `npx skills add LichAmnesia/lich-skills --skill google-analytics -a codex`. Or copy the skill folder (skills/google-analytics in LichAmnesia/lich-skills) into .agents/skills/google-analytics in your project. Codex loads it when a task matches its description.

Can I use Google Analytics 4 Analysis in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add LichAmnesia/lich-skills --skill google-analytics -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/google-analytics, .gemini/skills/google-analytics, .github/skills/google-analytics and .opencode/skills/google-analytics in your project.

What does Google Analytics 4 Analysis need to run?

Going by SKILL.md and its folder, Google Analytics 4 Analysis needs TypeScript for the scripts in its folder, the command-line tools its instructions call (bun, npx and npm) and credentials named GOOGLE_APPLICATION_CREDENTIALS. Our summary lists: A GA4 property ID; A Google service account key with Viewer access to the property; Bun, or Node.js with npx tsx.

Does Google Analytics 4 Analysis access the network?

SKILL.md names 1 domain. As links in the text: bun.sh. This is read from the text; nothing was executed.

Is Google Analytics 4 Analysis safe to install?

Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Google Analytics 4 Analysis use?

Google Analytics 4 Analysis is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Google Analytics 4 Analysis use?

About 2k tokens (SKILL.md is roughly 8.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Google Analytics 4 Analysis?

Skills that share tags, products or a category with Google Analytics 4 Analysis: Google SEO APIs (AgriciDaniel/claude-seo, 18k stars), Analytics (Nexus-JPF/note-companion, 869 stars), GEO Monthly Delta Report (zubair-trabzada/geo-seo-claude, 11k stars) and Analytics Tracking (borghei/Claude-Skills, 874 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Google Analytics 4 Analysis?

LichAmnesia (a GitHub user) maintains it in LichAmnesia/lich-skills, which has 234 GitHub stars. The repository holds 11 skills in this directory. The repository was last updated on June 9, 2026.

Source: LichAmnesia/lich-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.