public static void StartGame() { //DONE // Track in TopAnalytics that a game has started TopAnalytics.TrackEvent("game_start"); currentGameIndex++; }
public static void OnAdShown() { lastAdShownTime = Time.unscaledTime; lastAdShownGameIndex = currentGameIndex; adLoaded = false; TopAnalytics.TrackEvent("ad_shown"); LoadAd(); }
static public void RevokeConsent() { TopAds.RevokeConsent(); TopAnalytics.InitWithConsent(false); if (!PlayerPrefs.HasKey("consent") || PlayerPrefs.GetInt("consent") != 0) { PlayerPrefs.SetInt("consent", 0); PlayerPrefs.Save(); } }
static public void GrantConsent() { TopAds.GrantConsent(); TopAnalytics.InitWithConsent(true); if (!PlayerPrefs.HasKey("consent") || PlayerPrefs.GetInt("consent") == 0) { PlayerPrefs.SetInt("consent", 1); PlayerPrefs.Save(); } }
public static void SetGDPRConsent(bool gdprConsent) { TopAnalytics.InitWithConsent(gdprConsent); TopAds.InitializeSDK(); if (gdprConsent) { TopAds.GrantConsent(); } else { TopAds.RevokeConsent(); } }
// Before calling methods in TopAds and TopAnalytics you must call their init methods // TopAds requires the TopAds prefab to be created in the scene // You also need to collect user GDPR consent and pass that boolean value to TopAds and TopAnalytics // You can collect this consent by displaying a popup to the user at the start of the game and then storing that value for future use public static void StartGame() { UnityEngine.Assertions.Assert.IsTrue(RGPDManager.RgpdConsentalue.HasValue); TopAds.InitializeSDK(); TopAnalytics.InitWithConsent(RGPDManager.RgpdConsentalue.Value); if (RGPDManager.RgpdConsentalue.Value) { TopAds.GrantConsent(); } else { TopAds.RevokeConsent(); } // Track in TopAnalytics that a game has started TopAnalytics.TrackEvent(GAME_STARTED_EVENT); TopAds.OnAdShownEvent += TopAds_OnAdShownEvent; }
// TODO Before calling methods in TopAds and TopAnalytics you must call their init methods // TopAds requires the TopAds prefab to be created in the scene // TODO You also need to collect user GDPR consent and pass that boolean value to TopAds and TopAnalytics // You can collect this consent by displaying a popup to the user at the start of the game and then storing that value for future use /** * @requires calling the Initialize method first */ public static void StartGame() { /** * GDPR CONSENT * We Asynchronously Collect this consent by displaying a popup to the user * we pass the consent to the SDK in the initialization Method alongslide the app ID * @see An example at [MainCanvasScript.cs] */ // use the ConsentGiven to init TopAnalytics TopAnalytics.InitWithConsent(ConsentGiven); // init TopAds TopAds.InitializeSDK(); // Grant/Revoke TopAds based on consentGiven value if (ConsentGiven) { TopAds.GrantConsent(); } else { TopAds.RevokeConsent(); } // Track in TopAnalytics that a game has started TopAnalytics.TrackEvent("Game_started"); // Delegate TopAds events to listeners to ensure that we always have an ad ready :) TopAds.OnAdLoadedEvent += OnAdLoadedEvent; TopAds.OnAdFailedEvent += OnAdFailedEvent; TopAds.OnAdShownEvent += OnAdShownEvent; // we request an ad to prepare for the ShowAd Event :) TopAds.RequestAd(appAdUnitID); gamesSinceLastAd++; }
/* * ************************************************ * * TopAds Action events * Ad readiness/display events * * An autorequest system that ensures an ad is always ready to be displayed * * ************************************************ */ /** * this is a delegate of TopAds.OnAdShownEvent * Track in TopAnalytics when an ad is displayed. */ private static void OnAdShownEvent() { // Track in TopAnalytics when an ad is displayed. TopAnalytics.TrackEvent("ad_displayed"); // since ad is displayed, we turn this to false and to allow requesting a new one adLoaded = false; // Prepare for the next ad TopAds.RequestAd(appAdUnitID); Debug.Log("Ad shown, requesting for next time"); gamesSinceLastAd = 0; // The number of seconds that have elapsed since 1970-01-01T00:00:00Z. // needed to compare later secondsSinceLastAd = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); }
public static void EndGame() { // Track in TopAnalytics that a game has ended TopAnalytics.TrackEvent(GAME_ENDED_EVENT); GamesPlayedSinceLastAd++; }
private static void TopAds_OnAdShownEvent() { TopAnalytics.TrackEvent(AD_DISPLAYED_EVENT); TimeLastAdShown = Time.time; GamesPlayedSinceLastAd = 0; }
public static void EndGame() { //DONE // Track in TopAnalytics that a game has ended TopAnalytics.TrackEvent("game_end"); }
public static void EndGame() { TopAnalytics.TrackEvent("gameEnded"); // Track in TopAnalytics that a game has ended }
public static void StartGame() { gamesShown++; TopAnalytics.TrackEvent("gameStarted"); // Track in TopAnalytics that a game has started }