Game Analytics with GA4: A Setup That Actually Tells You Something
Game Analytics with GA4: A Setup That Actually Tells You Something
Honesty note: my game doesn’t run GA4 yet — a $0-budget game doesn’t need granular data in month one, and my site runs cookieless (EU consent). This is the setup I’d implement the day I have a question tracking answers: which events to send, how to structure them, and where the traps are.
TL;DR
- GA4 for games is event-based: send game events (level_start, level_complete, tutorial_complete, ad_impression), not just pageviews. GA4’s web stream sends a
page_viewby default; your game events are custom. - The events that matter for a casual game (the honest set):
level_start,level_complete,game_over,tutorial_complete,ad_watched(rewarded),ad_available/ad_error(SDK health). That’s a retention funnel + a monetization pulse, nothing more. - Measure with parameters, then aggregate: every event carries
level_number,score,moves,duration_s. GA4 lets you build funnels/explorations from these — the reason to collect is the funnel (who reaches level 10?) and the monetization math (ad views per session). - The three traps: (1) portal-embedded games (CrazyGames/Poki) can’t run your GA4 inside their iframe — track on your hosted build, not the portal build; (2) EU players need consent before GA4 cookies fire — consent mode or cookieless alternative (consent guide); (3) session data is not game session data — define game sessions yourself.
The event schema (copy-paste for a casual game)
// GA4 custom events — the minimal honest set
gtag('event', 'level_start', { level_number: n, difficulty: 'normal' });
gtag('event', 'level_complete', { level_number: n, moves: m, score: s, duration_s: t });
gtag('event', 'game_over', { level_number: n, score: s, best_score: b });
gtag('event', 'tutorial_complete', { duration_s: t });
// monetization pulse
gtag('event', 'ad_watched', { ad_type: 'rewarded', level_number: n });
gtag('event', 'ad_error', { error: e.code, level_number: n });
Why this exact set:
- Retention funnel:
level_start→level_complete→ nextlevel_start= the funnel that answers “do players keep playing?” (the metric that matters). - Monetization pulse:
ad_watchedper session andad_errorrate tell you if rewarded ads work without SDK dashboards (SDK reality). - Tutorial drop-off:
tutorial_completerate is a first-hour red flag.
Setup steps (30 minutes)
- Create a GA4 property → Data Streams → Web → your game URL → get the Measurement ID.
- Add the GA4 snippet to your game’s
index.html(thegtag.jstag), or use a consent-aware loader. - Send custom events at the game hooks (above) — plain
gtag()calls, no SDK needed for the web build. - Configure events in GA4 (optional): mark
level_completeetc. as conversions if you want them in reports; build a funnel exploration: level_start → level_complete → game_over. - Set consent mode for EU traffic (or stay cookieless — the honest choice).
The portal-embed problem (read this twice)
You cannot run your own GA4 inside a CrazyGames/Poki iframe. Portal builds are served on their domains with their SDKs — your analytics tag either won’t load (CSP/iframes) or double-counts the portal’s own telemetry. What this means:
- Portal build: rely on the portal’s analytics (they provide real-time dashboards — Poki’s developer stats, CrazyGames’ dashboard).
- Your own hosted build (your site, itch embed, Cloudflare-hosted): this is where GA4 belongs and where your events are clean.
- The two datasets measure different audiences — label them accordingly (distribution reality).
Pitfalls
- Pageviews only — a game is not a brochure; without game events you learn nothing about play.
- GA4 in the portal iframe — double-counted or blocked; track your own build, not theirs.
- No consent gate for EU — GA4 cookies before consent = ePrivacy breach (consent guide); use consent mode or cookieless.
- Trusting GA4 sessions as game sessions — GA4 sessions ≠ play sessions; send your own session markers if session data matters.
- Collecting data you don’t use — every extra event is cost and noise; the minimal set above answers the real questions.
Bottom line
GA4 for a game is event-based and small: six custom events (level start/complete, game over, tutorial, ad watched, ad error) with parameters, feeding one retention funnel and one monetization pulse. Set it up on your own hosted build (not portal iframes), gate EU consent properly, and skip tracking entirely until you have a question it answers — my game and site currently ship without it, by design, with cookieless privacy as the default.