Skip to content

Analytics SDK

Every game published from Klik Engine ships pre-wired with the Klik analytics SDK. Players' sessions, custom events, funnels, and A/B tests flow into a per-game dashboard without any manual setup - the engine writes the tracking calls during generation and registration happens automatically at publish time.

What you get out of the box

  • Sessions - starts, ends, duration, and outcomes, tracked automatically.
  • Custom events - the generation engine defines and tracks events that fit the game (level completed, power-up picked, and so on).
  • Funnels - multi-step progression tracking.
  • End-of-game flow - klik.endGame() sequences the outcome event, leaderboard submission, reward earning, and the leaderboard overlay in a single call.

The klik.* API

The SDK exposes a global klik object inside every game:

CallPurpose
klik.ready(cb)Runs cb once the SDK is initialized (required before reading A/B variants).
klik.define(name, schema)Declares a typed custom event.
klik.track(name, props)Records an event occurrence.
klik.funnel(id).step(n, eventName)Declares funnel steps.
klik.endGame({ outcome, score, ... }, cb)The single call to make at win/lose - outcome, leaderboard, rewards, overlay.
klik.debug()Returns SDK state (gameId, endpoint, buffered events, defined events) for self-diagnosis.
klik.health()Pings ingestion and resolves { ok, ms, status }.

Game identity (gameId, analytics key, endpoint) is injected at runtime by the hosting page - never hard-coded into the game build. This means the same build works on klikg.com, in the IDE preview (where traffic is free and not billed), and even played from a downloaded ZIP on any host.

Working with analytics through the engine

Ask the engine's agent (in the IDE, or via a plan-mode API job) questions like "which weapon do players pick most?" or "where do players quit?" - it queries the game's real analytics data before answering, and can then implement changes based on what it finds.

Billing

Analytics is metered in TIK against the game owner (event ingestion is fractions of a TIK per event). IDE preview traffic and the owner's own plays are free. If the balance runs out, the SDK degrades to essentials-only session tracking until top-up - games never break.

Klik Engine - AI game creation.