Skip to content

Nostra Analytics

To integrate Glance analytics, use sendCustomAnalyticsEvent(), a js bridge method. Find the part of the codes for the game events (loading, start, end, replay, etc.) and call the respective analytics.

Game events

This section helps you understand when and how to fire the game events while integrating analytics:

game_load

Call game_load when the game successfully loads 100%. The object under this event has no value. Use the following code snippet to add game_load in your game:

sendCustomAnalyticsEvent( 'game\_load', {} )

game_start

Call game_start when the game starts after a player clicks the start button. Use the following code snippet to add game_start in your game:

sendCustomAnalyticsEvent( 'game\_start', {} )

game_level

Call game_level when a player starts a new level in the game. This event is applicable only to level-based games. The following are the scenarios that use the event:

  • When the player starts a level-based game for the first time in the session, call game_level with game_start.

  • The player moves to the next level by clicking the required game CTA.

The game data must have the values of the following keys:

Key Mandatory/Optional Data Type Description
level Mandatory Integer The level of games. Applicable for level-based games only.

Use the following code snippet to add game_level in your game:

sendCustomAnalyticsEvent( 'game_level', {
  level: <level no>
} )

level_completed

Call level_completed when a player wins or completes a game level. This event is applicable only to level-based games. The game data must have the values of the following keys:

Key Mandatory/Optional Data Type Description
level Mandatory Integer The level the player has won. Applicable for level-based games only.

Use the following code snippet to add level_completed in your game:

 sendCustomAnalyticsEvent( 'level_completed', {
  level: <current level no>
} )

game_end

Call game_end when the game or a level ends for a player. Make sure game_end triggers before game_replay. The event can have the following scenarios:

  1. The player loses all their lives (including the extra lives) in the game.

  2. The player skips the ads and does not earn extra lives.

  3. The player exits the rewarded ad, and the game ends.

  4. The player exits the game by clicking the game’s back button, home button, etc., during the game session.

  5. The player loses a level.

  6. The player clicks the home button after winning a level.

Key Mandatory/Optional Data Type Description
level MANDATORY Integer The level at which the player loses. Applicable for level-based games only.
score MANDATORY Integer The score of the current game session. Applicable only for scenarios 1, 2, and 3 of game_end. Do not use it for scenarios 4, 5, and 6.
highScore MANDATORY Integer The high score of the user till date. Applicable only for scenarios 1, 2, and 3 of game_end. Do not use it for scenarios 4, 5, and 6.

Use the following code snippet to add game_end in your game:

sendCustomAnalyticsEvent( 'game_end', {
  level: <level no>,
  score: <current score>,
  highScore: <user high score throughout the lifetime of the game>
} )

For scenarios 4,5, and 6, you can skip score and highScore parameters and the level is valid for the level-based games.

game_replay

Call game_replay when a player replays the game. Make sure game_replay triggers only after game_end. The scenarios for the event are as follows:

  • The player replays the game from the Leaderboard.

  • The player replays the game by clicking the replay or equivalent button.

  • The player returns to the Home screen and clicks the start or play button to replay the game or level. 

The game data must have the values of the following keys:

Key Mandatory/Optional Data Type Description
level Mandatory Integer The level of games. Applicable for level-based games only.
score Mandatory Integer The score of the game. The value is 0.
highScore Mandatory Integer The high score of the user till the date. The value is 0 for the games not having a score concept.
successCB Optional Any Pass the global function (can be called independently in any file) responsible for replaying the game.

Use the following code snippet to add game_replay in your game:

sendCustomAnalyticsEvent( 'game_replay', {
  level: <level no>,
  score: 0,
  highScore: <user high score throughout the lifetime of the game>,
  successCB: <Global function to replay the game>
} )

rewarded_ad

Trigger the rewarded_ad event and the rewardEvent() method when a player opts for the rewarded ad defined in the ads.js file.

This step is a must if you want to add a rewarded ad on a game screen.

The game data must have the values of the following keys:

Key Mandatory/Optional Data Type Description
successCB Mandatory Any The player has watched the complete ad. Gives a reward to the player after the video completes.
failureCB Mandatory Any The player has skipped the video before minimum watch time. Does not give the reward to the player.

Use the following code snippet to add rewarded_ad in your game:

sendCustomAnalyticsEvent( 'rewarded_ad', {
  successCB: <Global function to grant reward and go back to game>,
  failureCB: <Global function to go back to game without granting the reward>
} )

game_milestone

Call game_milestone when a player achieves a milestone in the game. Milestones can be score, time, number of collectibles, etc. The game data must have the values of the following keys:

Key Mandatory/Optional Data Type Description
type Mandatory String The milestone type
meta Mandatory Object Additional information
level Mandatory Integer The level of games. Applicable for level-based games only.
score Mandatory Integer The score of the game. The value is 0 for the games not having a score concept.
highScore Mandatory Integer The high score of the user. The value is 0 for the games not having a score concept.

Use the following code snippet to add game_milestone in your game:

sendCustomAnalyticsEvent( 'game_milestone', {
  type: <the type of the milestone>,
  meta: <Any other information>,
  level: <level no>,
  score: 0,
  highScore: <user high score throughout the lifetime of the game>
} )

game_life_end

Call game_life_end when a player loses his one life or equivalent in the game. This event is different from the game_end as game_life_end does not end the game but the life of the player. A player can have multiple lives in a game. The game data must have the values of the following keys:

Key Mandatory/Optional Data Type Description
level Mandatory Integer The current level of the game. Applicable for level-based games only.
score Mandatory Integer The score of the game. The value is 0 for the games not having a score concept.
highScore Mandatory Integer The high score of the user till that time. The value is 0 for the games not having a score concept.
remainingLife Mandatory Integer Number of the lives left for the player.

Use the following code snippet to add game_life_end in your game:

sendCustomAnalyticsEvent( 'game_life_end', {
  level: <level no>,
  score: <currentScore>,
  highScore: <user high score throughout the lifetime of the game>,
  remainingLife: <number of lives left>
} )

ingame_transactions

Call ingame_transactions when a player makes a transaction in the game, for example, buying skins, levels, coins, etc.

Key Mandatory/Optional Data Type Description
transactionType Mandatory String The object for which the transaction has been made.
meta Mandatory Object Additional information
level Mandatory Integer The current level of the game
score Mandatory Integer The current score of the game. The value is 0 for the games not having a score concept.
highScore Mandatory Integer The high score of the user till the time of transaction. The value is 0 for the games not having a score concept.

Use the following code snippet to add ingame_transactions in your game:

sendCustomAnalyticsEvent( 'ingame_transactions', {
  transactionType: <transactionType>,
  meta: <any other information>,
  level: <level no>,
  score: <currentScore>,
  highScore: <user high score throughout the lifetime of the game>
} )