Track Events
Tracking events allow us to report how each variation is performing. For example, if you are logging transactions, our web app will show you which variation is producing the most transactions. Using our Unity package, you can log ad activity, transactions, and custom events.
Initializing Elecular
Before we start logging events, we must first initialize Elecular by calling the initialize method in a Start or Awake function.
using Elecular.API;
using UnityEngine;
public class GameManager : MonoBehaviour
{
void Start()
{
ElecularApi.Instance.InitializeWithTracking();
}
}Logging Events
An ad impression must be logged whenever an ad is displayed to a user. An ad click must be logged whenever a user clicks an ad.
//Import Statement
using Elecular.API;
//Logging Ad Impression
ElecularApi.Instance.LogAdImpression("ad-placement-id");
//Logging Ad Click
ElecularApi.Instance.LogAdClick("ad-placement-id");Field
Type
Description
Example
Placement Id
string
Placement id of the ad
reward-video
Transaction events must be logged when a user makes a purchase. The m at the end of 0.99m signifies that the number is a decimal.
//Import Statement
using Elecular.API;
//Logging Transaction
ElecularApi.Instance.LogTransaction("product-id", 0.99m);Field
Type
Description
Example
Product Id
string
Name of the product
500-coin-pack
Price
decimal
Price of the product in USD
0.99m
You can track custom events such as level completion, button clicks, deaths etc.
Field
Type
Description
Example
Event Name
string
Name of the event
level-complete
Amount
decimal
Arbitrary amount
Amount of coins collected in the level
Debug Window
To verify if you are logging events as expected, you can drag the Debug Window prefab into the scene. This prefab is under Elecular/Debug Window. This Debug Window shows all the events that are emitted from Elecular.
Last updated
Was this helpful?