# Engine event snippet generator

> Pick your engine and events to get copy-paste analytics code for GameMaker, Construct, Defold, LÖVE, Ren'Py, Bevy, Pico-8, RPG Maker or Phaser. Free.

Canonical URL: https://manalens.dev/tools/engine-event-snippet-generator

Pick your engine and the events you want, and get copy-paste code that sends them to an HTTP analytics API. It covers 9 engines without an official SDK. The code keeps events in an offline queue, retries with backoff, sends nothing before the player consents, and uses the engine's own HTTP and save functions.

## Engine event snippet generator

## How to use this tool

The interactive tool runs in the browser at https://manalens.dev/tools/engine-event-snippet-generator. This section describes it for readers who cannot run it.

### Inputs

- Engine: GameMaker, Construct 3, Defold, LÖVE (Love2D), Ren'Py, Bevy, Pico-8, RPG Maker MZ or Phaser
- Publishable key, endpoint, store, game version, build and game name
- Events: level start, level complete, level fail, resource, purchase, tutorial complete, and up to 10 of your own snake_case names
- Ask for consent first (yes or no)

### Outputs

- The setup code from our guide for that engine, with your values filled in: an offline queue saved to disk, batches of up to 50, retries with backoff, events older than 7 days dropped, and nothing sent before consent
- One track call per event in the engine's syntax, with the example properties of our event conventions
- A text file of all blocks and a link that keeps the engine and events (never the key)

## How to use it

1. Pick your engine: GameMaker, Construct 3, Defold, LÖVE (Love2D), Ren'Py, Bevy, Pico-8, RPG Maker MZ, and Phaser.
2. Enter your publishable key, your game version, the build and the store. The key stays in your browser.
3. Tick the events to add, such as level start, level complete and level fail, and type your own event names if you need more.
4. Copy each block into the file its label names, then copy the event calls into your gameplay code.
5. Run a development build, check that the response has "rejected":0, and copy the link to this setup for your team.

## How it works

The generator does not write new network code. It takes the code from our analytics guide for each engine, where every engine function is checked against the engine's official manual, and fills in your key, endpoint, version, build, store and game name. It then writes one track call per event in your engine's syntax.

Every event is the same JSON envelope that the Godot, Unity, and Unreal SDKs send: type "track", channel "app", a new UUID version 4 as message_id, a saved UUID as anonymous_id, a session_id, an ISO 8601 timestamp and context.app with platform, store, version, build and engine "other". The code sends up to 50 events per request.

The queue is saved to disk, so events survive a crash or a lost connection. A batch is kept and retried later after a network error, a 5xx, 408 or 429 response, with a longer wait each time. It is dropped after any other 4xx. Events older than 7 days are dropped before sending, because the API refuses a batch that holds one.

```
request = POST {endpoint}/v0/events with x-publishable-key and {"events": [1 to 50 events]}
retry wait = 2 seconds, doubled after each failure, at most 300 seconds
send = only events newer than 7 days, only after consent
```

## Worked example

### Example with made-up inputs: Defold, version 0.9.2, build 204, two events

With Defold picked, the generator fills main/analytics.lua from the Defold guide with your key, version "0.9.2", build "204" and library_name "lighthouse". It then writes 2 calls in Lua table syntax: manalens.track("level_complete", { level = 3, attempt = 1, score = 1200 }) and manalens.track("resource", { flow = "sink", currency = "gold", amount = 250, item = "potion" }).

The level_complete call has 3 properties and the resource call has 4, as in our event conventions. If a player finishes 60 levels offline, the queue holds 60 events and sends them in 2 requests of up to 50 when the connection returns.

## How to read the result

Paste the setup blocks once, then call track from your gameplay code where each moment happens. Keep the example property names, such as level, attempt and score, so every build sends the same names.

Keep the consent box ticked unless you have checked that you may collect analytics without asking. With it ticked, the code sends nothing and saves no ID until the player agrees, and it deletes the ID and the queue when they say no.

Set build to dev in the first test build, so you can filter those events out later. Our practice is to check one batch, then switch off the network, play for a minute and check that the queued events arrive once.

## Why not use an old analytics tutorial?

Many engine tutorials still send events to Google Universal Analytics, which Google shut down in 2023, so that code sends nothing. Others send one request per event with no queue, which loses events offline and on quit. This code queues to disk, sends in batches, retries with backoff and respects consent, which is what an SDK does for you in Unity, Godot, or Unreal.

## Which events should I send first?

Start with the moments that show where players stop: level start, level complete and level fail, with the level and the attempt. Add resource events if your game has an economy, and purchase events if it sells anything. The setup code already sends game open, session start and session end, so retention and playtime work from the first build.

## Limits

It covers 9 engines without an official Manalens SDK. Unity, Godot, and Unreal have official SDKs that do this for you. GDevelop, MonoGame, Raylib, HaxeFlixel and Stride have guides but are not in the generator yet.

The code is a starting point that you own. It does not add your consent screen, a settings toggle or a privacy notice, and you should test it on every platform you ship.

Pico-8 has no HTTP inside the cart. Its code sends a numeric event code and one value through GPIO to the HTML page, so it works only in the web export.

## Which tool should I use?

Use this generator for the code. Use the game tracking plan generator to decide which events and properties your game needs first, and the crash-free rate calculator once error events come in.

- [Game tracking plan generator](https://manalens.dev/tools/game-tracking-plan-generator)
- [Crash-free rate calculator](https://manalens.dev/tools/crash-free-rate-calculator)

## Frequently asked questions

**How do I add analytics to a GameMaker game?**

Use http_request() with a header map and a JSON body, and read the reply in the Async HTTP event. Pick GameMaker in this generator to get the Create event code with a saved player ID, a buffer file queue, retries and consent, plus a track call for each event you pick. Our GameMaker guide explains each line.

**Does the code work offline?**

Yes. Each event goes into a queue that is saved to disk, or to local storage on web exports. The code sends up to 50 events per request when it can, keeps the batch after a network error and tries again later with a longer wait, and drops events older than 7 days, which the API would refuse.

**Is the publishable key safe to put in my game?**

Yes. The publishable key can only send events, not read any data, so it is made to ship in a game build. Never put the secret key in a game: it belongs on your server only. The generator refuses a key that does not look like a publishable key, so a pasted secret key shows a warning.

**How does the consent flag work?**

With consent on, the code sends no event and saves no player ID until you call the consent function with true, for example from a button on your first screen. Calling it with false deletes the ID and the queue. You build the screen and the text. The generator shows the exact consent call for your engine.

**Can I use this code with another analytics backend?**

The queue, retry and consent parts work with any HTTP endpoint, but the event format is the Manalens app event envelope, sent with an x-publishable-key header. Another backend needs its own body and headers. For Manalens, the same events also join the website visits and Steam data of the same project.

**Is my key sent anywhere?**

No. The code is built in your browser from guide code that is already on the page. Your key, endpoint, version and build are not sent to our server and are not saved in the page link. Only the engine and the events you tick are kept in the link, so a shared link opens the same setup.

## Sources

- [Manalens documentation: App and game events (HTTP).](https://docs.manalens.dev/sdks/app-events), read 2026-11-23
- [Manalens documentation: Events API, POST /v0/events.](https://docs.manalens.dev/api/events), read 2026-11-23
- [IETF, RFC 9562: Universally Unique IDentifiers (UUIDs), version 4.](https://www.rfc-editor.org/rfc/rfc9562), read 2026-11-23

Last reviewed 2026-11-23. The code is built in your browser. Your key, endpoint and build are not sent to our server and are not kept in the page link.

## Related guides, tools and terms

### Guides

- [Engine analytics compared: Unreal, Godot, GameMaker, Construct, Phaser](https://manalens.dev/blog/game-engine-analytics-compared)
- [What events to track first in your game](https://manalens.dev/blog/game-tracking-plan-first-events)
- [How to add analytics to a GameMaker game](https://manalens.dev/blog/gamemaker-analytics)
- [How to add analytics to a Defold game](https://manalens.dev/blog/defold-analytics)

### Tools

- [Game tracking plan generator](https://manalens.dev/tools/game-tracking-plan-generator)
- [D1, D7, D30 retention calculator](https://manalens.dev/tools/retention-calculator)
- [Crash-free rate calculator](https://manalens.dev/tools/crash-free-rate-calculator)

### Glossary

- [What is a funnel step?](https://manalens.dev/glossary/funnel-step)
- [What is a cohort in game analytics?](https://manalens.dev/glossary/cohort)

## Next step

Once events arrive, Manalens shows retention, level funnels, playtime and errors by build, next to your Steam wishlists and website visits for the same players. [See player analytics](https://manalens.dev/features/retention)

## Guides that use this tool

- [How to add analytics to a Construct 3 game](https://manalens.dev/blog/construct-3-analytics)
- [How to add analytics to a Bevy game](https://manalens.dev/blog/bevy-analytics)
- [How to add analytics to a Phaser game](https://manalens.dev/blog/phaser-analytics)
- [How to add analytics to a LÖVE (Love2D) game](https://manalens.dev/blog/love2d-analytics)
- [How to add analytics to an RPG Maker MZ game](https://manalens.dev/blog/rpg-maker-mz-analytics)
- [How to add analytics to a Ren'Py game](https://manalens.dev/blog/renpy-analytics)
- [How to add analytics to a Pico-8 game](https://manalens.dev/blog/pico-8-analytics)

[Explore more game tools](https://manalens.dev/tools)

Interactive tool: https://manalens.dev/tools/engine-event-snippet-generator
