quiver-dev / quiver-analytics-godot-plugin

Track how players are interacting with your Godot game, while still respecting their privacy.
MIT License
17 stars 2 forks source link

Quiver Analytics

Quiver Analytics allows you to collect analytics for games made with the Godot engine in a privacy-friendly way. In just a few minutes, you can integrate Analytics in your game through this open source plugin and gain valuable insight into how players are interacting with your game. You also have fine-grained control over how your players' privacy is handled.

Guidelines

Before you get started, note that Quiver Analytics is meant to be used to collect non-identifying information about your players to understand how your game is played while respecting their privacy. Please do not send personal information like names, email addresses, physical addresses, phone numbers, IP addresses, or any other identifying information to Quiver Analytics. Doing so may cause your account to be restricted. If you have any questions, give us a shout.

Prerequisites

This plugin requires Godot 4.0 or later. It's been designed to work with GDScript. We'll add support for other languages in the future.

Installation

Usage

The Analytics autoload is added to your project automatically when you enable the plugin.

Adding an event

To send an event, call:

Analytics.add_event(event_name, properties)

where event_name is the name of the event (should be 50 characters or less) and properties is an optional dictionary with key/values with additional properties that describe the event.

Here's an example:

Analytics.add_event("Completed level", {"level": 2, "usedSpecialPower": false})

By default, player consent isn't required for anonymous data collection, but if you activate required consent, calls to this function will be ignored until consent is received.

Cleaning up before exiting the game

Before you quit the game, you can tell the plugin to send a configurable "Quit game" event and flush any outstanding events. To do that, write this code anywhere you are exiting the game:

await Analytics.handle_exit()

Note that SceneTree.quit() will immediately exit the game so you want to make sure you wait for the above call to finish before calling the quit() function.

Note for web and mobile games:

If you are developing a web or mobile game, it might be difficult to call handle_exit() since you don't always have the option to run operations when a player backgrounds the app or closes the tab. To work around this, we have added some special logic to automatically add 'Quit game' events. Note that the timing of this event is an estimate and might be up to a minute off the actual quit time.

Advanced Usage

The following is not required, but you do have additional functionality if you need it.

Managing consent

By default, the plugin won't ask for consent since no personally identifying information is collected. However, you can enable opt-in data collection by going to Project Settings -> Quiver -> Analytics and set "Player Consent Required" to true. Now calls to add_event() will be ignored until you obtain consent. To manage consent, you can either use the built-in UI:

if Analytics.should_show_consent_dialog():
  Analytics.show_consent_dialog(parent_node)

This will decide whether consent has already been granted or denied and, if not, will spawn a consent dialog as a child of the parent_node.

If you'd like to use your own UI and manually handle consent management, you can use the following functions:

# Variable storing whether consent has been requested
Analytics.consent_requested
# Variable storing consent status
Analytics.consent_granted
# Function to call if consent was granted
Analytics.approve_data_collection()
# Function to call if consent was denied
Analytics.deny_data_collection()

Customizing consent UI

By default, the built-in consent UI will use whatever UI theme that has been set for your project. You can modify this by changing the properties of the ConsentDialog found in /addons/quiver_analytics/consent_dialog.tscn.

Advanced Settings

If you turn on Advanced Settings for Project Settings -> Quiver -> Analytics, you'll find the following properties:

More Information

Default Properties

The plugin will automatically add the following default properties to all events:

All default property names start with a "$".

Notes and Limitations

Troubleshooting

License

MIT License