agentleFS
LichAmnesiaLichAmnesia/lich-skills/skills/google-analytics/SKILL.md

google-analytics

Skill233 starsChanged 7 months agoMITView on GitHub

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.

  • Reads credentials
  • Installs packages

13 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use backlink-audit, search-console and 4 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • OpenClaudiaSkill

    backlink-audit

    Audit a domain's backlink profile using the SemRush API. Use when the user says "audit backlinks", "check my backlinks", "backlink analysis", "link profile", "toxic links", "disavow", "link building opportunities", "referring domains", "anchor text", or asks about a site's link authority.

    Also in 3 projects that use this

  • OpenClaudiaSkill

    search-console

    Pull Google Search Console data and perform search performance analysis. Use when asked about search rankings, clicks, impressions, CTR, index coverage, Core Web Vitals, or sitemap status. Trigger phrases: "search console", "GSC", "search performance", "clicks and impressions", "CTR analysis", "index coverage", "core web vitals", "URL inspection", "sitemap status", "ranking data", "search queries", "keyword positions".

    Also in 3 projects that use this

  • webrenewSkill

    google-ads

    Plan, build, audit or run Google Ads search campaigns for a local service business (plumber, dentist, roofer, cleaner, lawyer, clinic) on a small budget, with the agent drafting and the owner approving every change that spends money. Use this skill for a new Google Ads account or campaign, keyword research from customer questions, match types, negative keywords, location targeting, responsive search ads and assets, landing page message match, conversion tracking from GA4 or the Google Ads tag, budgets and bidding, Local Services Ads, a weekly check, and when the user says "PPC", "Google Ads is not working", "too expensive per lead", "wasted ad spend", "search terms" or "should we run Google ads".

    Also in 4 projects that use this

  • hoodiniSkill

    meta-ads

    Run Meta ads end to end like a PPC specialist: install and verify the pixel on a funnel, launch Sales campaigns, read the data, find where the funnel leaks, fix campaigns live, build stage-by-stage remarketing, and monitor daily. Pull, analyze, manage, and CREATE Meta ads (Facebook, Instagram, Messenger, Threads, Click-to-WhatsApp) via the Marketing API. Use when the user mentions Meta/FB/IG ads, Ads Manager, ROAS, CPA, CPM, CTR, ad spend, campaign or ad set performance, creative fatigue, frequency, CTWA, audience/placement breakdowns, A/B ad tests, or wants to pause an ad, change a budget, duplicate a winner, or launch a new campaign from scratch, install or debug a Meta pixel (פיקסל), set up remarketing (רימרקטינג, קהלים מותאמים, מי שביקר ולא קנה), or wants ongoing monitoring of a live campaign. Also covers reconciling ads with real sales from the checkout/course platform (Schooler MCP, סקולר, רב מסר) and turning past buyers, sign-ups that didn't pay and non-starters into cross-sell and recovery campaigns. Runs in Claude and in Grok Bot (גרוק בוט): install into a bot, run the daily check as a routine, alert on Telegram/WhatsApp. Trigger on Hebrew terms like פרסום בפייסבוק/באינסטגרם, פרסומות מטא, ביצועי קמפיין, פרסומות, צור קמפיין, השק קמפיין, A/B טסט. Trigger on questions like how are my ads doing, which creative is winning, is my ad fatigued, what's my CPA, drop a 30-day report, launch an A/B test for my course, build a campaign with these 3 angles. Trigger even if auth isn't set up - the skill walks through one-time setup. Do NOT use for organic Instagram analytics, Reels view counts on non-promoted posts, or organic Threads engagement; those need the Instagram Graph API.

    Also in 3 projects that use this

  • indranilbanerjeeSkill

    keyword-research

    Research keywords via the connected data source: intent, gaps. Grouping → keyword-cluster. \"what keywords should we target\"

    Also in 3 projects that use this

  • SentrySkill

    programmatic-seo

    When the user wants to create SEO-driven pages at scale using templates and data. Also use when the user mentions "programmatic SEO," "template pages," "pages at scale," "directory pages," "location pages," "[keyword] + [city] pages," "comparison pages," "integration pages," or "building many pages for SEO." For auditing existing SEO issues, see seo-audit.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When the user asks an analytics question:

    line 107

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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)

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

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.

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.

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

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

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):

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

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.