analytics
Skill4 starsChanged 5 months agoMITView on GitHub
Add, enable, or swap analytics providers, or add a tracked event. Use when the user wants to turn on PostHog or Google Tag Manager, plug in another analytics tool (Plausible, Fathom, GA4, Umami, …), disable analytics, or track a new event.
41 other projects use a version of this.
Adopted by
Most recently taken up by
- t0ddharris/compound-marketingtheir own version, first seen Oct 5, 2026
- HanksChen0110/skillstheir own version, first seen Oct 3, 2026
- growthbook/skillstheir own version, first seen Sep 30, 2026
- philtzjp/skillstheir own version, first seen Sep 30, 2026
- productionx-in/Core-Skillstheir own version, first seen Sep 29, 2026
- tandregbg/core-claude-skillstheir own version, first seen Sep 27, 2026
Used with
Projects with it also use popups, co-marketing and 10 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.
CesarjoquinSkillpopups
When the user wants to create or optimize popups, modals, overlays, slide-ins, or banners for conversion purposes. Also use when the user mentions "exit intent," "popup conversions," "modal optimization," "lead capture popup," "email popup," "announcement banner," "overlay," "collect emails with a popup," "exit popup," "scroll trigger," "sticky bar," or "notification bar." Use this for any overlay or interrupt-style conversion element. For forms outside of popups, see cro. For general page conversion optimization, see cro.
Also in 15 projects that use this
CesarjoquinSkillco-marketing
When the user wants to find co-marketing partners, plan joint campaigns, or brainstorm partnership opportunities. Use when the user says 'co-marketing,' 'partner marketing,' 'joint campaign,' 'who should we partner with,' 'integration marketing,' 'cross-promotion,' 'collaborate with another company,' 'partnership ideas,' or 'co-brand.' For customer referral programs, see referrals. For launch-specific partnerships, see launch.
Also in 14 projects that use this
coreyhaines31Skillmarketing-council
When the user wants multiple expert perspectives on a marketing question — a simulated board of advisors staffed by legendary marketers (Seth Godin, David Ogilvy, Eugene Schwartz, April Dunford, Rory Sutherland, Alex Hormozi, Byron Sharp, and more). Also use when the user mentions 'marketing council,' 'board of advisors,' 'advisory board,' 'what would Seth Godin say,' 'what would Ogilvy think,' 'channel Hormozi,' 'get multiple perspectives,' 'debate this,' 'have the council review,' 'marketing mentors,' or asks how a famous marketer would approach their problem. The council gives each advisor's take through their documented frameworks, surfaces where they disagree, and synthesizes a recommendation. For executing the winning direction, hand off to positioning, offers, copywriting, ads, or the relevant skill.
Also in 8 projects that use this
ukunal91appSkillcommunity-marketing
Build and leverage online communities to drive product growth and brand loyalty. Use when the user wants to create a community strategy, grow a Discord or Slack community, manage a forum or subreddit, build brand advocates, increase word-of-mouth, drive community-led growth, engage users post-signup, or turn customers into evangelists. Trigger phrases: "build a community," "community strategy," "Discord community," "Slack community," "community-led growth," "brand advocates," "user community," "forum strategy," "community engagement," "grow our community," "ambassador program," "community flywheel.
Also in 16 projects that use this
ScaleBrickSkillcompetitors
Audit competitors using ScaleBrick's 3-surface framework (social, web/pages, SEO). Categorizes their pricing, features, and landing pages. Identifies gaps you can exploit, positioning angles no one is claiming, and specific moves you can make this week.
Also in 14 projects that use this
roerohanSkillemails
When the user wants to create or optimize an email sequence, drip campaign, automated email flow, or lifecycle email program. Also use when the user mentions "email sequence," "drip campaign," "nurture sequence," "onboarding emails," "welcome sequence," "re-engagement emails," "email automation," "lifecycle emails," "trigger-based emails," "email funnel," "email workflow," "what emails should I send," "welcome series," or "email cadence." Use this for any multi-email automated flow. For cold outreach emails, see cold-email. For in-app onboarding, see onboarding.
Also in 13 projects that use this
- +6 more from Cesarjoquin
Other versions41 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 41
- coreyhaines31/marketingskills★ 53ksame name
- getsentry/sentry★ 45ksame name
- Cesarjoquin/Marketing-Skills★ 197same name
- TheAceTeam/CC-Flight★ 93same name
- grainulation/grainulator★ 86same name
- AlekseiUL/sprut-agent-kit★ 65same name
- open-fox/agents★ 55same name
- SZcalligrapher/slash-skills-subscription★ 32same name
- growthbook/skills★ 23same name
- ayrshare/ayrshare-social-media-api-claude-plugin★ 19same name
31 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- brandSkill
- imagesSkill
- og-imagesSkill
- redirectsSkill
- runSkill
- structured-dataSkill
- update-depsSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 1 is distinctive, and 3 are very specific to this project.
0
Common
Most of the 37 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 7
Add/enable/swap analytics providers and tracked events.
- Very specific: line 11
Call sites never name a vendor.
- Distinctive: line 23
Ask the user only if unclear.
- Very specific: line 152
Keep src/env.d.ts, AGENTS.md → Analytics, and SETUP.md → §5 in sync whenever the provider set changes.
“Common” is measured: kept by at least 6 in 10 of the 37 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.
Files
Analytics
Add/enable/swap analytics providers and tracked events. The system is provider-agnostic and supports multiple providers at once.
The system
Call sites never name a vendor. They fire events through a global facade — window.track(event, props), always called optionally (window.track?.(...)) so an unconfigured site is a silent no-op. Each active provider chains onto window.track (wrapping the previous one), so one call fans out to every provider.
src/components/analytics/*.astro— one component per provider. Each exports its own committed config constant(s) (not env vars — these are public, non-secret values), renders its loader snippet, and defines/extendswindow.track.src/components/Analytics.astro— the dispatcher. Imports each provider's constant(s), computes an enable flag from them, and renders it. All providers are further gated on one global switch,PUBLIC_ANALYTICS_ENABLED === "true"— off by default, so nothing fires unless that env var is explicitly"true". A provider whose constant is empty emits nothing either way — no 404ing script, no Lighthouse Best-Practices hit.- Tracked events fire from inline scripts across layouts, pages, and components — see the Tracked events (catalog) section below for the full list and where each lives.
Built-in providers: PostHog (POSTHOG_PROJECT_TOKEN + POSTHOG_HOST constants in posthog.astro) and Google Tag Manager (GTM_CONTAINER_ID constant in gtm.astro, empty by default).
PUBLIC_ANALYTICS_ENABLED (src/env.d.ts) is set to "true" in your host's production env and in CI for pushes to main (.github/workflows/ci.yml) — leave it unset anywhere you want analytics off (dev, PRs, previews). The full picture is in AGENTS.md → Analytics.
Step 1 — Figure out the task
Ask the user only if unclear. The four jobs:
- A. Enable a built-in provider (PostHog / GTM) → fill in its constant, no other code. Step 2.
- B. Add a new provider (Plausible, Fathom, GA4, Umami, …) → the recipe. Step 3.
- C. Add a tracked event → Step 4.
- D. Disable analytics → Step 5.
Step 2 — Enable a built-in provider (A)
Set the provider's committed constant (values are public/non-secret, so this is a normal code change, not a deploy-time secret):
- PostHog —
POSTHOG_PROJECT_TOKENandPOSTHOG_HOSTinsrc/components/analytics/posthog.astro(both required, or PostHog stays off). - GTM —
GTM_CONTAINER_IDinsrc/components/analytics/gtm.astro(e.g.GTM-XXXXXXX). Wire the actual tags (GA4, Ads, …) inside the GTM UI; match tracked events with a Custom Event trigger on the event name.
Both can be on at once. Once their constants are filled in, analytics still stays off until PUBLIC_ANALYTICS_ENABLED=true (production env, or CI on main). To test locally, prefix the dev/build command with it.
PostHog CSP host. The snippet loads its script from (script-src) and sends events to (connect-src) POSTHOG_HOST, so that origin must be in the CSP or the browser blocks it in production. A cross-origin host needs an explicit allowlist entry — PostHog Cloud (app.posthog.com) is cross-origin, and so is a reverse-proxy subdomain on your own domain. It's hard-coded as a literal (in script-src and connect-src) in src/headers/headers.config.ts — keep it in sync with the POSTHOG_HOST constant in posthog.astro. The value is duplicated on purpose: headers.config.ts compiles into a committed, drift-checked public/_headers artifact that can only import plain TS modules, not .astro component exports, so the CSP needs its own literal. After editing either one, run npm run build:headers and commit the regenerated public/_headers.
Step 3 — Add a new provider (B)
Four steps. Let <p> be the provider slug (e.g. plausible).
Component — create
src/components/analytics/<p>.astro: frontmatter exports the provider's config as a committed constant (not an env var — these are public, non-secret values) fordefine:vars; the body is a single top-level<script is:inline>(keep it top-level — a script wrapped in a{ }expression breaks Prettier's Astro parser) that (a) loads the vendor library and (b) chains ontowindow.track:--- export const PLAUSIBLE_DOMAIN = ""; const domain = PLAUSIBLE_DOMAIN; --- <script is:inline define:vars={{ domain }} defer data-domain={domain} src="https://plausible.io/js/script.manual.js"></script> <script is:inline> window.track = (function (prev) { return function (event, props) { if (prev) prev(event, props); window.plausible && window.plausible(event, { props: props }); }; })(window.track); </script>The chaining wrapper (
prev= the previously-installedtrack) is the load-bearing part — it's what lets providers coexist. Maptrack(event, props)to the vendor's own call. Prop support varies: PostHog/GTM/GA4/Plausible carry props; Fathom's lower tiers ignore them — that's fine, treat props as best-effort.Facade mappings for common vendors:
Provider track(event, props)→GA4 (gtag) gtag('event', event, props)Plausible plausible(event, { props })Fathom fathom.trackEvent(event)(no props)Umami umami.track(event, props)Dispatcher — in
src/components/Analytics.astro, import the component and its constant, add an enable flag from it, and render it:import Plausible, { PLAUSIBLE_DOMAIN } from "@/components/analytics/plausible.astro"; const plausibleEnabled = !!PLAUSIBLE_DOMAIN;{analyticsEnabled && plausibleEnabled && <Plausible />}- Window globals — if the vendor exposes a new global, add it to the
Windowinterface insrc/env.d.ts(likeposthog/dataLayer). No env var declaration needed — the config constant lives in the component itself. - CSP — allowlist the vendor's script/connect (and any pixel
img-src) hosts in thecspDirectivesinsrc/headers/headers.config.ts(the source of truth — not the generatedpublic/_headers), then runnpm run build:headersand commit the regenerated artifact. Without this the browser blocks the script in production. GTM already ships allowlisted; a new provider needs its own host added. (See the PostHog CSP host note in Step 2 for why hosts are duplicated as literals here rather than imported from the component.)
Step 4 — Add a tracked event (C)
Fire it from the relevant inline script with the neutral facade — never name a vendor:
window.track?.("event_name", { some_prop: value });Copy the pattern from an existing call site (e.g. src/layouts/BaseLayout.astro → contact_email_clicked, or src/components/Prose.astro → code_block_copied). Keep event names snake_case. Then add a row to the catalog below (event, where fired, properties). To associate the visitor with an id (e.g. after a form submit), call window.identify?.(id) — it fans out the same way.
Tracked events (catalog)
The events this starter fires today. All go through window.track(...) and reach every active provider. Property support varies by provider — GTM/PostHog carry full props; some vendors (e.g. Fathom) ignore them.
| Event | Where fired | Properties |
contact_email_clicked | BaseLayout.astro | email |
post_viewed | blog/[...slug].astro | post_slug, post_title |
post_navigation_clicked | PostLayout.astro | direction, destination_slug |
code_block_copied | Prose.astro | snippet_length |
resource_gate_viewed | forms/brevo.astro | resource_slug, form_id |
resource_gate_submitted | forms/brevo.astro | form_id, resource_slug |
resource_download_confirmed | thank-you/[...slug].astro | resource_name, resource_url |
resource_downloaded | thank-you/[...slug].astro | resource_name, asset_url |
resource_gate_submitted is preceded by an identify(email) call. (Every resource-funnel event shares the resource_ prefix.)
Lead-magnet gate funnel: resource_gate_viewed → resource_gate_submitted → resource_download_confirmed (reached the thank-you page) → resource_downloaded (clicked the direct download).
Step 5 — Disable analytics (D)
- Everywhere it's currently off by default (dev, PRs, previews) — nothing to do.
- In production — remove/unset
PUBLIC_ANALYTICS_ENABLED=truefrom the host's env config. - One provider only — blank its constant(s) (
GTM_CONTAINER_ID = ""ingtm.astro, or both PostHog constants inposthog.astro). It then emits nothing regardless of the switch.
Step 6 — Verify
npm run format # class/format order is plugin-enforced
npm run check # 0 errors
npm run lint
npm run build # must passThen confirm the rendered output — a plain npm run build stays off (not a production deploy), so force it on with PUBLIC_ANALYTICS_ENABLED=true and grep dist/:
PUBLIC_ANALYTICS_ENABLED=true npm run build >/dev/null 2>&1
grep -c "posthog.init\|gtm.js?id=" dist/index.html # each active provider present
grep -oc "window.track = (function (prev)" dist/index.html # one chain per active provider
grep -oc 'window.track?.(' dist/index.html # call sites use the facadeAlso check the default-off case (the Lighthouse guarantee): a plain npm run build with no override → grep -c "posthog.init\|gtm.js?id=" dist/index.html returns 0 regardless of the provider constants. If a provider loads client-side, /run the dev server with PUBLIC_ANALYTICS_ENABLED=true and confirm the network request + a test event in the vendor dashboard.
Notes
- Keep
src/env.d.ts,AGENTS.md→ Analytics, andSETUP.md→ §5 in sync whenever the provider set changes. - The chaining wrapper must run before the event listeners fire.
<Analytics />is in<head>and listeners are at end of<body>, so ordering holds — don't move<Analytics />below the body scripts. - GTM's
<noscript>iframe is intentionally omitted: it belongs in<body>, and no-JS users can't fire our JS events anyway.
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
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.

