Send game events from Godot or Defold
Count what players do in your game, such as levels finished, or a score or time, with a small script, and read the numbers on the Game Analytics page.
更新日:11月 3, 2026 · この記事は英語です。
AIアシスタントを使っていますか? ルールとスクリプトをまとめたブリーフをコピーして、ゲームのコードと一緒にアシスタントに貼り付けると、イベントを追加してもらえます。
Your game can send events, such as level_complete or boss_defeated, and you see how often each happened on the Game Analytics page (in the menu under your name). An event can also carry one number, such as a score or a time, and you see its average, lowest and highest. It is a small way to learn where players get stuck or what they enjoy.
How it works
A game here cannot reach the internet, so it does not call our servers itself. Instead it hands each event to the game page it is running in, and the page passes it on. You do not need a key or an account setting. Events are counted for your game while it is live.
- Only the event name and the optional number are sent. There is no player and no cookie, so you see counts and totals, not people. The single numbers are not kept: for each day we keep how many events had a number, their sum, the lowest and the highest.
- A name uses lowercase letters, digits, dots, dashes and underscores, up to 40 characters, for example
level_3.complete. Capital letters are turned into lowercase, and anything else is ignored. - A number can be a whole number or a decimal, between -1,000,000,000 and 1,000,000,000. Anything else is ignored, and the event is still counted without it.
- A game keeps up to 50 different names. Events with a new name after that are ignored, so pick a small set.
- Your own team, moderators and robots are not counted, like views and plays. To test, open the live game in a private window while signed out.
- Counts are by day. They may arrive a few seconds late, and a page sends a limited number of events per visit, so do not send one on every frame.
Godot 4
- Download indiedev.gd and put it in your project.
- In Project Settings, Globals (Autoload) add it with the name
IndieDev. - Call it anywhere in your game:
IndieDev.event("level_complete")
IndieDev.event("level_time", 83.5)
It does nothing outside a web export, so it is safe to leave in while you test on your computer.
Defold
- Download indiedev.lua and put it in your project.
- Use it from any script:
local indiedev = require("indiedev")
indiedev.event("level_complete")
indiedev.event("level_time", 83.5)
It does nothing outside an HTML5 build.
Other engines
Download indiedev.js, put it in your zip next to index.html and load it with <script src="indiedev.js"></script>. Then call:
indiedevEvent("level_complete");
indiedevEvent("level_time", 83.5);
Or skip the file and send the message yourself, which is all the scripts above do:
window.parent.postMessage({ indiedev: 1, type: "event", name: "level_time", value: 83.5 }, "*");
Leaderboards
The same scripts can also keep a ranking of your players' best scores or times. That is in beta and has its own guide: add a leaderboard to your game.
Reading the numbers
Open Game Analytics from the menu under your name and choose your game. It lists each name with its count for the range you chose, the last 7 days and all time. For events that carried a number it also shows the average, lowest and highest in that range. Names and counts stay with the game until you delete it.