Set Up Game Events
Wait for Game Event Manager initialisation
Please wait for Game Event Manager initialisation before using any of the integration event calls.
public void Start()
{
if(!CodaGameManager.Instance.AnalyticsManager.IsInitCompleted())
{
CodaGameManager.Instance.AnalyticsManager.InitCompleted += OnGameEventManagerInitialized;
}
else
{
OnGameEventManagerInitialized();
}
}
void OnGameEventManagerInitialized()
{
//Send Game Event
}
For Coda SDK to work properly, developers should dispatch integration events to their code. All events that are required to be dispatched for integration are listed under Game Event Management module Integration Events. Developers can access these events by following lines
CodaGameManager.Instance.GameEventManager.IntegrationEvents...
Start Level
Start Level Event
This event should be sent whenever a new level is started by the player.
Event Parameters:
- currentLevel : int - the level index that the user is about the play.
- playerCoins : int - the total amount of soft currency that the player has when starting this level.
- parameters : List - additional arguments for advanced usage.
Example Code:
CodaGameManager.Instance.GameEventManager.IntegrationEvents.StartLevel(int currentLevel, int playerCoins, List<CustomEventParameter> parameters = null);
Set Level Progress
Set Level Progress
This event should be sent whenever the player progression in the level is needed to be recorded.
Event Parameters:
- currentLevel : int - the level index that the user is about the play.
- levelProgressRatio : float - should be used to define how much the player has progressed in the current level, the value should be between 0 and 1.
- parameters : List - additional arguments for advanced usage.
Example Code:
CodaGameManager.Instance.GameEventManager.IntegrationEvents.SetLevelProgress(int currentLevel, float levelProgressRatio = 1f, List<CustomEventParameter> parameters = null)
Call this function whenever player progression change in the level need to be recorded 0 = 0% , 1.0 = 100%
Track Level Progress
Track Level Progress
This event should be sent whenever the player progression in the level is needed to be tracked, you do not need to track every progression change. This method is to be used for milestones reached within the level.
Event Parameters:
- currentLevel : int - the level index that the user is about the play.
- levelProgressRatio : float - should be used to define how much the player has progressed in the current level, the value should be between 0 and 1.
- parameters : List - additional arguments for advanced usage.
Example Code:
CodaGameManager.Instance.GameEventManager.IntegrationEvents.TrackLevelProgress(int currentLevel, float levelProgressRatio = 1f, List<CustomEventParameter> parameters = null)
Call this function whenever player progression change in the level need to be tracked 0 = 0% , 1.0 = 100%
Resume Level
Resume Level Event
This event should be sent whenever a player continues a level with a reason.
Event Parameters:
- currentLevel : int - the level index that the user is about the play.
- levelProgressRatio : float - should be used to define how much the player has progressed in the current level, the value should be between 0 and 1. (0 = 0% progress , 1.0 = 100% progress)
- resumeLevelSource : enumReason for resuming the level.
- parameters : List - additional arguments for advanced usage.
Reason :
- RewardedVideo
- GameCoin
- Free
CodaGameManager.Instance.GameEventManager.IntegrationEvents.ResumeLevel(int currentLevel, float levelProgressRatio = 1f, ResumeLevelSource resumeLevelSource = ResumeLevelSource.RewardedVideo, List<CustomEventParameter> parameters = null);
Finish Level
Finish Level Event
This is to be sent after a user has completed a level.
Event Parameters:
- levelSuccess : boolean - should be true if a player has successfully completed a level, false otherwise.
- currentLevel : int - the level index that the user is about the play.
- levelProgressRatio : float - should be used to define how much the player has progressed in the current level, the value should be between 0 and 1. (0 = 0% progress , 1.0 = 100% progress)
- parameters : List - additional arguments for advanced usage.
CodaGameManager.Instance.GameEventManager.IntegrationEvents.FinishLevel(bool levelSuccess, int currentLevel, int playerCoins, float levelProgressRatio = 1f, List<CustomEventParameter> parameters = null);
Call this function when a level is ended for good it can be either fail or success. For levels which were continued after watching a rewarded ad, you should not call this in the first fail.
Skip Level Reward Applied
This function needs to be called whenever a player skips the level by watching a rewarded ad video.
CodaGameManager.Instance.GameEventManager.IntegrationEvents.SkipLevelRewardApplied()
New Tracking Event
New Tracking Event
Custom events can be used for any analytics events that are not predefined. You can define the event's id/key and the custom parameters that it sends to the analytics services.
- eventId : string - the key or name of the event.
- parameters : List - pairs are respectively names and the values for each parameter. You can have as many as you want, but usually services do not accept more than 7 or 10 parameters for each event. An event with no parameters also is an option. Just include the event id and null parameter list.
CodaGameManager.Instance.GameEventManager.IntegrationEvents.NewTrackingEvent(string eventID, List<CustomEventParameter> parameters)
Call this function to track a new custom event.
IAP Request
IAP Request
This event should be sent whenever the player sends an in-app product buy request.
Event Parameters:
-> currencyCode : Local currency code. USD, EUR, TRY etc. You can get currency code when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check out iso currency codes to find your local currency code.-> amount : Local Price. You can get local price when purchase if successful or fail but while requesting the purchase you need to enter this float manual. Check your store page to find your local prices.
-> productType : Product Type that comes with Unity IAP, inside ProcessPurchase method. There are 3 product types, "Consumable", "NonConsumable", "Subscription". Write these manually while requesting the purchase. You can get these from Unity IAP, inside ProcessPurchase method after purchase is handled.
-> productId : Product Id that comes with Unity IAP, inside ProcessPurchase method. You can get product id when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check your store page to find your item's product id.
-> cartType : Where does this item belong. e.g Shop Item/End page.
Example Code:
CodaGameManager.Instance.GameEventManager.IntegrationEvents.IAPRequest(string currencyCode, float amount, string productType, string productId, string cartType);
Call this function to track a new in-app product buy request.
IAP Response
IAP Response
This event should be sent whenever an in-app product's buy request has a response callback. Like "OnPurchaseSuccessful"
Event Parameters:
-> receipt : Receipt that comes with Unity IAP, inside ProcessPurchase method if purchase is successfull, if not leave it blank.-> currencyCode : Local currency code. USD, EUR, TRY etc. You can get currency code when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check out iso currency codes to find your local currency code.
-> amount : Local Price. You can get local price when purchase if successful or fail but while requesting the purchase you need to enter this float manual. Check your store page to find your local prices.
-> productType : Product Type that comes with Unity IAP, inside ProcessPurchase method. There are 3 product types, "Consumable", "NonConsumable", "Subscription". Write these manually while requesting the purchase. You can get these from Unity IAP, inside ProcessPurchase method after purchase is handled.
-> productId : Product Id that comes with Unity IAP, inside ProcessPurchase method. You can get product id when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check your store page to find your item's product id.
-> cartType : Where does this item belong. e.g Shop Item/End page.
-> status : Status of response. true(Successful), false(Failed).
Example Code:
CodaGameManager.Instance.GameEventManager.IntegrationEvents.IAPResponse(string receipt, string currencyCode, float amount, string productType, string productId, string cartType, bool status);
Call this function to track a new in-app product response callback.
Subscription Request
Subscription Request
This event should be sent whenever the player sends a subscription buy request.
Event Parameters:
-> currencyCode : Local currency code. USD, EUR, TRY etc. You can get currency code when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check out iso currency codes to find your local currency code.-> amount : Local Price. You can get local price when purchase if successful or fail but while requesting the purchase you need to enter this float manual. Check your store page to find your local prices.
-> productType : Product Type that comes with Unity IAP, inside ProcessPurchase method. There are 3 product types, "Consumable", "NonConsumable", "Subscription". Write these manually while requesting the purchase. You can get these from Unity IAP, inside ProcessPurchase method after purchase is handled.
-> productId : Product Id that comes with Unity IAP, inside ProcessPurchase method. You can get product id when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check your store page to find your item's product id.
Example Code:
CodaGameManager.Instance.GameEventManager.IntegrationEvents.SubscriptionRequest(string currencyCode, float amount, string productType, string productId);
Call this function to track a new subscription buy request.
Subscription Response
Subscription Response
This event should be sent whenever subscription request has a response callback. Like "OnSubscriptionSuccessful"
Event Parameters:
-> receipt : Receipt that comes with Unity IAP, inside ProcessPurchase method if purchase is successfull, if not leave it blank.-> currencyCode : Local currency code. USD, EUR, TRY etc. You can get currency code when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check out iso currency codes to find your local currency code.
-> amount : Local Price. You can get local price when purchase if successful or fail but while requesting the purchase you need to enter this float manual. Check your store page to find your local prices.
-> productType : Product Type that comes with Unity IAP, inside ProcessPurchase method. There are 3 product types, "Consumable", "NonConsumable", "Subscription". Write these manually while requesting the purchase. You can get these from Unity IAP, inside ProcessPurchase method after purchase is handled.
-> productId : Product Id that comes with Unity IAP, inside ProcessPurchase method. You can get product id when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check your store page to find your item's product id.
-> status : Status of response. true(Successful), false(Failed).
Example Code:
CodaGameManager.Instance.GameEventManager.IntegrationEvents.SubscriptionResponse(string receipt, string currencyCode, float amount, string productType, string productId, bool status);
Call this function to track a new subscription response callback.
Updated 7 months ago