Helper Functions
LionAnalytics provides global functions to affect future events.
AB Testing
AbCohort()
AbCohort()
Overview: The method should be fired every session. If a user is in multiple AB tests, the event should be fired multiple times. This will attach the cohort information to all events.
Returns:
void
Parameters:
Parameter
type
Required
Description
experimentName
string
Required
The experiment name
experimentCohort
string
Required
The cohort name
additionalData
dictionary
Optional
Any additional information associated with failing to initiate the system. Such as more details error message, attempts, elapsed time etc.
ClearAbCohort()
ClearAbCohort()
Overview: Clear an AbCohort Experiment (Not commonly used). Only use this if you set up client code to check for FeatureFlags during a session and can resond to players changing experiment participation mid-session.
Returns:
void
Parameters:
Parameter
type
Required
Description
experimentName
string
required
Name of the abCohort experiment to clear from proceeding events.
Additional Data
SetGlobalAdditionalData()
SetGlobalAdditionalData()
Overview: This method allows developers to add their own global parameter values that will be fired off with every subsequent event.
Returns:
void
Parameters overload 1:
Parameter
type
Required
Description
map
Dictionary
Required
Developers can pass a Dictionary<string, object> and the event will loop through and add all the desired key value pairs.
Parameters overload 2:
Parameter
type
Required
Description
item
string
Required
The name of the data to add to as a global parameter value.
val
object
Required
The value associated with the key of the global parameter.
ClearGlobalAdditionalData()
ClearGlobalAdditionalData()
Overview: Clears an entry in the developer provided global additional data
Returns:
void
Parameters:
Parameter
type
Required
Description
key
string
Required
The name of the item to remove.
ClearGlobalAdditionalData()
ClearGlobalAdditionalData()
Overview: Clears all the developer provided global additional data
Returns:
void
Parameters: None
AddInitializationInfo
()
AddInitializationInfo
()
Overview: This method adds key-value data that will be included in the game_started event's additional_data. If called after game_started event has already been automatically sent, the data will be sent as a separate debug event instead. We recommend to call this method in a
[RuntimeInitializeOnLoadMethod]
marked method to ensure it is included with the game_started event. You can call this method multiple times to add more data. See code example hereReturns:
void
Parameters:
Parameter
type
Required
Description
key
string
Required
The name of the item to add.
value
obje
ct
Required
The value of the item you want to include.
Player data
SetPlayerLevel()
SetPlayerLevel()
Overview: This method sets the global Player Level (account) value that will be attached to all events. It should be called anytime the Player Level changes.
Returns:
void
Parameters:
Parameter
type
Required
Description
playerLevel
integer
Required
This is the value of the player’s account level (not gameplay level).
ClearPlayerLevel()
ClearPlayerLevel()
Overview: Clear a players level, and remove the tracking from other events
Returns:
void
Parameters: None
SetPlayerScore()
SetPlayerScore()
Overview: This method sets the global Player Score value that will be attached to all events.
Returns:
void
Parameters:
Parameter
type
Required
Description
userScore
integer
Optional
This is the value of the player’s score.
ClearPlayerScore()
ClearPlayerScore()
Overview: Clear a players score, and remove the tracking from other events
Returns:
void
Parameters: None
SetPlayerXP()
SetPlayerXP()
Overview: This method sets the global Player XP (experience) value that will be attached to all events. It should be called anytime the Player XP changes.
Returns:
void
Parameters:
Parameter
type
Required
Description
playerXp
integer
Required
This is the value of the player’s XP (experience).
ClearPlayerXP()
ClearPlayerXP()
Overview: Clear Player XP.
Returns:
void
Parameters: None
Monetization
SetCurrencyBalance()
SetCurrencyBalance()
Overview: This method sets the Currency Balance that will be attached to all events. It should be called anytime that currency is spent or received. to all events. It should be called anytime that virtual currency is spent or received.
Returns:
void
Parameters: Parameters:
Parameter
type
Required
Description
type
string
Required
The type of currency (typically soft
or hard
)
name
string
Required
The name of the currency
balance
integer
Required
The new value of the player’s balance for that currency.
type
and name
are case-sensitive.
Consider using public constants to avoid typos.
SetItemBalance()
SetItemBalance()
Overview: This method sets the Item Balance that will be attached to all events. It should be called anytime that item is used or received. to all events. It should be called anytime that real currency is spent or received.
Returns:
void
Parameters:
Parameter
type
Required
Description
type
string
Required
The type of item
name
string
Required
The name of the item
balance
integer
Required
The new value of the player’s balance for that item.
type
and name
are case-sensitive.
Consider using public constants to avoid typos.
Game Data
GetTotalTimeInApp()
GetTotalTimeInApp()
Overview: Returns the time in app variable that is being tracked on to all LA events currently.
Returns:
int
Parameters: None
SetTutorial()
SetTutorial()
Overview: Set Tutorial
Returns:
void
Parameters:
Parameter
type
Required
Description
tutorialState
bool
Required
Value used to determine if an event is a tutorial or not.
trackMission
string
Required
Used to check internally if a tutorial has started or finished.
RemoveLevelAttemptTrackingData()
RemoveLevelAttemptTrackingData()
Overview: Clears internal attempt number tracking data for a specified level. You should not need this.
Returns:
void
Parameters:
Parameter
type
Required
Description
levelNum
integer
Required
Game Level being played.
levelCollection1
string
Required
Collection of Game Levels. The second-order grouping.
levelCollection2
string
Required
Collection of lower level collections (second-order). The third-order grouping.
missionType
string
Required
Indicate the type of the mission, level, task, quests etc. (within the level).
missionName
string
Required
Name of side Mission that takes place within a Game Level.
RemoveMissionAttemptTrackingData()
RemoveMissionAttemptTrackingData()
Overview: Clears internal attempt number tracking data for a specified mission You should not need this.
Returns:
void
Parameters:
Last updated