Custom Events

Understanding the performance of your playables beyond the ad network metrics is key to optimising your creative.

Luna captures a number of standard events automatically for every playable that is created for a supporting ad network (see more).

On top of this, our custom events API allows you to track specific events within your playable that will help you understand the user flow and drop off points within the ad.

All custom events are in the Luna.Unity.Analytics namespace.

When implementing custom events, please avoid logging any event during the initialisation phase of your game i.e. in the Awake method.

Custom event limits

In order to avoid misuse or user-code errors, Luna enforces two limits on custom events.

  • 256 events logged per playable session

You can log up to 256 events in a given playable session (per user). After 256 logged events, any subsequent events will be dropped by the server.

  • 32 events per unique event name

You can log up to 32 events per unique event in a given playable session (per user). After 32 logged events, any subsequent events will be dropped by the server.

Pre-defined custom events

Luna provides a number of commonly used and useful custom events to be used in your playable. These events will also have pre-built reporting template in Luna Playground's Insights pages.

Each event has a name and optional integer parameter.

Note: The optional integer parameter is NOT optional when passing a string as the first parameter to the LogEvent function instead of an EventType
  • TutorialStarted - the playable has presented the tutorial.
  • TutorialComplete - the user has completed the tutorial.
  • LevelStart - a level was started.
  • LevelWon - the user won a level.
  • LevelFailed - the user failed a level.
  • LevelRetry - a user retried a level.
  • Score - submit a score to Luna Insights.
  • EndCardShown - the end card was shown.

Implementation Example

public void GameEnded() {
if (levelWon) {
Luna.Unity.Analytics.LogEvent(Luna.Unity.Analytics.EventType.LevelWon, 1);
} else {
Luna.Unity.Analytics.LogEvent(Luna.Unity.Analytics.EventType.LevelFailed, 1);
}
// Log the game ended event
Luna.Unity.LifeCycle.GameEnded();
ShowEndCard();
}
public void ShowEndCard() {
// Show the end card
Luna.Unity.Analytics.LogEvent(Luna.Unity.Analytics.EventType.EndCardShown);
}

Open custom events

If your game has specific experiences which you want to measure, and the needs aren't met via one of the pre-defined events detailed above, you can also use your own custom events.

This API allows you to pass in any string, which will be logged and available for reporting in Luna Insights.

Implementation Example

For example, the user opens a chest to reveal a prize:

public void OpenedChest() {
Luna.Unity.Analytics.LogEvent("chest_opened", 1);
}

Testing Custom Events in Luna Playground

You can find out all you need to know on this here.