Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question When to send an adImpression Analytics event relative to the ad?

Discussion in 'Unity Ads & User Acquisition' started by Rabadash8820, Feb 24, 2023.

  1. Rabadash8820

    Rabadash8820

    Joined:
    Aug 20, 2015
    Posts:
    87
    I am using the Unity Analytics SDK (the new UGS one) with a 3rd party ad mediation framework (Appodeal). I want to send standard
    adImpression
    analytics events when ad impressions occur in my game. These events can have many parameters (see screenshot from UGS Analytics Event Manager below). However, the
    adHasClicked
    param has left me unsure of when to send one of these event relative to its ad.

    I see three options:
    1. Send the event after the ad is hidden, so that I know whether the player clicked on the ad and can set
      adHasClicked
      appropriately, but then I risk not sending an
      adImpression
      event at all if the player quits the game before the ad is hidden (e.g., during a long video ad, or during a "long-lived" banner ad).
    2. Send the event when the ad is first shown (which seems to be what most analytics frameworks do, based on some googling), but then
      adHasClicked
      will always be false, even if the player does ultimately click the ad.
    3. Send two events: one when the ad is first shown with
      adHasClicked
      false, and one after the ad is hidden with the param set appropriately. However, it feels wasteful to send two analytics events (with lots of mostly redundant params) for every ad impression.
    Can someone from the Unity Analytics or Ads teams make a recommendation here? Any guidance would be much appreciated!

    upload_2023-2-24_4-1-10.png
     
    Last edited: Feb 25, 2023
  2. aylin_unity3d

    aylin_unity3d

    Unity Technologies

    Joined:
    Apr 6, 2015
    Posts:
    45
    Hey, if you are using unityads sdk direct, I think you can call adHasClicked when
    OnUnityAdsShowClick is called.
    Please refer to this listener and OnUnityAdsShowClick
     
  3. Rabadash8820

    Rabadash8820

    Joined:
    Aug 20, 2015
    Posts:
    87
    I am not using Unity Ads directly, unfortunately; as I mentioned, I'm using Appodeal.
     
  4. Rabadash8820

    Rabadash8820

    Joined:
    Aug 20, 2015
    Posts:
    87
    However, I think I've come up with a decent way forward...

    • My custom
      AdsManager
      component (which wraps calls to the Appodeal SDK) keeps track of ads being clicked; then, when ads are closed, it writes an ad impression analytics event through
      AnalyticsManager
      with
      adHasClicked
      set appropriately.
    • I added an
      OnDestroy
      handler to
      AdsManager
      , so that it can still write an ad impression analytics event in case the game is quit while an ad is being shown.
    • I've set up my custom
      AnalyticsManager
      component (which wraps calls to the UGS
      AnalyticsService
      ) to be last in the execution order (under Project Settings), and added an
      OnDestroy
      handler that calls IAnalyticsService.Flush. Having
      AnalyticsService
      last in the execution order ensures that the final ad impression events (and any other analytics events triggered by components as they are destroyed) will still be flushed to UGS.
    With this system in place, I should be able to get the best of both worlds: ad impression events are always triggered once (and only once) when an ad is shown, and the event includes whether the ad was clicked!