Event Filter
Depending on your game, you may not need to fire all events all the time. Events cost money, so if some events aren’t needed right now, use our Event Filter to restrict events to the right level. All event are assigned a priority P0 (critical) to P5 (nice to have).
Introduction
From LionAnalytics 2.5+, events are now filtered on the client side before being fired. This was introduced to help reduce overall data costs. With this system, you do not need to modify your in-game event code when you aren’t doing analysis and want to pause or adjust the volume of events being collected.
We recommend setting up a Remote Configuration variables for Priority Level
and Whitelist Countries
, then connecting those variables with the LionAnalytics override methods:
SetWhitelistPriorityLevel()
AddWhitelistCountries()
The filter will decide whether to fire an event based on:
- the event name
- the player’s country
- the default filter settings (below)
- the overridden settings (below)
This means that not all events may be fired and you may be missing events when viewing LionAnalytics QA Tool or Looker dashboards.
This is normal, expected, and depends on your filter settings and country from where you are testing.
If someone (QA for example) reports missing events, first check your current filter setting and the country where they are testing to determine if this event should be showing up.
Default Filter Settings
The default filter settings are defined in a remote file here.
This file is downloaded and used by the Lion Analytics package. It is cached for offline use and refreshed every 24h.
This file contains:
whitelistPriorityLevel
- Defines which events can be fired from whitelisted countriesdefaultPriorityLevel
- Defines which events can be fired from non-whitelisted countrieseventsPriorityLevels
- Defines the priority of each event.whitelistCountries
- Defines the list of countries that are considered whitelist, and usingwhitelistPriorityLevel
instead ofdefaultPriorityLevel
.
An event will be fired if the priority level associated with this event is lower or equal to the priority level associated with the player’s country tier (whitelist or default).
So a
PX
event will be fired if:player’s country is in
whitelistCountries
andwhitelistPriorityLevel
isPX+
OR
player’s country is not in
whitelistCountries
anddefaultPriorityLevel
isPX+
More examples can be found in the Examples section below.
The event priority levels are ordered from highest to lowest priority of the event.
- P0 - always fired from all goes
Override Methods
You can override two settings of the filter locally:
- The countries in the whitelist
- The priority level for countries in the whitelist
Call the two override methods below when your game starts (in every session). These functions can be called anytime:
- If called before Analytics package initialization, the values will be stored and used during the initialization.
- If called after initialization, the settings will be updated for all subsequently fired events.
The parameters you pass to these methods should ultimately be controlled by remote configs (Satori, Firebase…).
💡 | If you integrated Lion’s LiveOps package, you can check Connect Lion Analytics Filters checkbox in Satori tab of Lion Settings. It will automatically use the Feature Flags ⚠️ This setting will only take effect after LiveOps package is initialised. If you are firing an analytics event before this package is initialised, the remote configured analytics filters will not apply for that event. |
SetWhitelistPriorityLevel()
- Overview: Set Priority level for whitelisted countries to send events
- Returns:
void
- Parameters:
Parameter | type | Required | Description |
---|---|---|---|
priorityLevel | enum | Required | Value used to determine what is the priority level for whitelisted countries to send events |
Signature
LionAnalytics.SetWhitelistPriorityLevel(EventPriorityLevel priorityLevel)
Example
LionAnalytics.SetWhitelistPriorityLevel(EventPriorityLevel.P4);
This will set the priority level for whitelisted countries to P4
. This means events P0
-P4
will be fired for these countries. You can only override to a higher level than the one in the default settings file.
This method is case-sensitive, please provide uppercase letters.
AddWhitelistCountries()
- Overview: Add to the list of whitelist countries to fire events
- Returns:
void
- Parameters:
Parameter | type | Required | Description |
---|---|---|---|
countries | list | Required | Value used to add to the list of existing whitelisted countries where events are being sent |
Signature
LionAnalytics.AddWhitelistCountries(List<string> countryCodes)
The countryCodes must be 2-letters codes using the standard ISO 3166-1 alpha-2.
Example
LionAnalytics.AddWhitelistCountries(new List<string>() {"in", "tr"});
This will add India and Turkey to the whitelistCountries
. So if the player is in one of these countries, they will now be using whitelistPriorityLevel
instead of defaultPriorityLevel
.
You cannot remove countries from the default list.
Key Takeaways
- Each event has a priority level
- There are two country tiers: whitelisted & non-whitelisted
- Whitelisted countries use
whitelistPriorityLevel
- Non-whitelisted countries use
defaultPriorityLevel
- Whitelisted countries use
- Default event priority levels and whitelisted geos are loaded from default settings file - No Action Needed
- Developers have two methods to override the settings of the events filter:
AddWhitelistCountries()
SetWhitelistPriorityLevel()
- Note only whitelisted GEOs will fire events with the following priority:
- P1 events are fired when
SetWhitelistPriorityLevel()
is set toP1
-P5
- P2 events are fired when
SetWhitelistPriorityLevel()
is set toP2
-P5
- P3 events are fired when
SetWhitelistPriorityLevel()
is set toP3
-P5
- P4 events are fired when
SetWhitelistPriorityLevel()
is set toP4
-P5
- P5 events are fired when
SetWhitelistPriorityLevel()
is set toP5
- P1 events are fired when
- We recommend hooking up Remote Config variables so you can change these values remotely without requiring a build and release.
Examples
Example #1
- Situation:
- The game code calls
SetWhitelistPriorityLevel()
with parameterP3
- The player is in China
- The game fires
interstitial_show
- The game code calls
- Result:
- You overrode the default level from
P1
toP3
. So allP0
,P1
, andP3
events are expected to show up for valid geos. - China is in the whitelist countries - so China is valid, and we don’t expect the event to be blocked based on location.
- Reviewing the default settings file, we see that
interstitial_show
isP1
. - Since
P1
≤P3
and China is valid, the event will be fired.
- You overrode the default level from
Example #2
- Situation:
- The game code calls
SetWhitelistPriorityLevel()
with parameterP3
. - The player is in China
- The game fires
interstitial_show_fail
- The game code calls
- Result:
- You overrode the default level from
P1
toP3
. So allP0
,P1
, andP3
events are expected to show up for valid geos. - China is in the whitelist countries - so China is valid, and we don’t expect the event to be blocked based on location.
- Reviewing the default settings file, we see that
interstitial_show_fail
isP4
. - While China is valid,
P4
>P3
, so the event will not fire.
- You overrode the default level from
Example #3
- Situation:
- The game code calls
SetWhitelistPriorityLevel()
with parameterP4
. - The player is in China
- The game fires
interstitial_show_fail
- The game code calls
- Result:
- You overrode the default level from
P1
toP4
. So allP0
,P1
,P3
, andP4
events are expected to show up for valid geos. - China is in the whitelist countries - so China is valid, and we don’t expect the event to be blocked based on location.
- Reviewing the default settings file, we see that
interstitial_show_fail
isP4
. - China is valid and
P4
≤P4
, so the event will fire.
- You overrode the default level from
Example #4
- Situation:
- The game code calls
SetWhitelistPriorityLevel()
with parameterP4
. - The player is in Turkey
- The game fires
interstitial_show_fail
- The game code calls
- Result:
- You overrode the default level from
P1
toP4
. So allP0
,P1
,P3
, andP4
events are expected to show up for valid geos. - Turkey is not a whitelist countries. Unless you call
AddWhitelistCountries
to add Turkey, onlyP0
andP1
events from Turkey will be seen. - Reviewing the default settings file, we see that
interstitial_show_fail
isP4
. - While you set the override to
P4
, and this event isP4
, Turkey is not whitelisted so onlyP0
andP1
events will fire from Turkey. So, this event will not fire.
- You overrode the default level from
Example #5
- Situation:
- The game code calls
SetWhitelistPriorityLevel()
with parameterP4
. - The game code calls
AddWhitelistCountries
with parametertr
(Turkey) - The player is in Turkey
- The game fires
interstitial_show_fail
- The game code calls
- Result:
- You overrode the default level from
P1
toP4
. So allP0
,P1
,P3
, andP4
events are expected to show up for valid geos. - You overrode the default country whitelist and added Turkey, so Turkey is now valid. We don’t expect the event to be blocked based on location.
- Reviewing the default settings file, we see that
interstitial_show_fail
isP4
. - Turkey is valid and
P4
≤P4
, so the event will fire.
- You overrode the default level from