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.
  2. Dismiss Notice

Feedback Application.RequestAdvertisingIdentifierAsync and UnityAds

Discussion in 'Unity Ads & User Acquisition' started by SamTyurenkov, Jan 19, 2021.

  1. SamTyurenkov

    SamTyurenkov

    Joined:
    May 12, 2018
    Posts:
    83
    Hi,

    From other threads I read that
    Application.RequestAdvertisingIdentifierAsync method Android support was removed for Unity 2020+

    Unity Team members told, it was a required step for apps that dont use Ads and dont use tracking. I can understand that.

    But, in apps where UnityAds is installed, this method should be a part of UnityAds API.
    Because UnityAds does send an idfa for attribution. So a developer should have access to the method as well.

    Does it make sense? Or maybe there is a way to get Advertising ID if you have UnityAds package already?
     
  2. kyle-unity

    kyle-unity

    Unity Technologies

    Joined:
    Jan 6, 2020
    Posts:
    336
    Hey @SamTyurenkov I just checked in my test project and I'm able to get the advertising ID using RequestAdvertisingIdentifierAsync.

    This is with the latest version of 2019 LTS, which has the fix mentioned in your linked thread. I'm downloading 2020.2 now and will test it there too and report back here.

    Edit: With the same project in 2020.2 it does look like RequestAdvertisingIdentifierAsync has been disabled. We don't currently have an equivalent method in the Unity Ads SDK.
     
    Last edited: Jan 21, 2021
    Novack likes this.
  3. SamTyurenkov

    SamTyurenkov

    Joined:
    May 12, 2018
    Posts:
    83
    Well, I can't downgrade anymore, files become corrupted.

    That method is really needed for install tracking, would be great if you add it into Unity Ads package.
    I saw you have one in a standalone Unity Ads package for Android apps made without in Unity.

    Or maybe a guide how to implement it in Docs, Java plug-ins story is a bit hard to understand.
     
    Last edited: Jan 21, 2021
    Novack likes this.
  4. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    840
    I also asumed it was moved into the Unity Ads SDK. I was able to retrieve it through third party ads sdks, but it would be more than convenient to have it on Unity itself. Accesing it behind a custom define as @kyle-unity initially suspected would be the solution to the original issue, which was avoiding to have it on all builds by default.
     
  5. kyle-unity

    kyle-unity

    Unity Technologies

    Joined:
    Jan 6, 2020
    Posts:
    336
    It doesn't really make sense to have it included with the Unity Ads SDK as the primary functionality of that SDK is to deliver ads and there shouldn't be any reason for publishers to need access to the advertising ID.

    I understand how it would be useful if you are building your own install attribution process, however, if you are working with us as an advertiser. I don't think the Ads SDK would be the place to put it, since that ought to remain geared towards publishers, but maybe there is a use case for an additional small plugin or package. I will start a discussion internally.
     
    Novack and SamTyurenkov like this.
  6. SamTyurenkov

    SamTyurenkov

    Joined:
    May 12, 2018
    Posts:
    83
    Actually, Java class for obtaining advertisment ID already present in the Unity Ads package, it just doesn't have a method for a developer to access it with C#.

    I hope it will be considered to add it. Thanks for looking into the problem.
     
  7. SamTyurenkov

    SamTyurenkov

    Joined:
    May 12, 2018
    Posts:
    83
    I'm sorry for asking that, I know its totally my fault that I upgraded the Unity to 2020 and didn't make a proper testing to find out that Application.RequestAdvertisingIdentifierAsync stopped worked.

    I stopped my advertising campaign as soon as I found that out. I know, because of that, I wasnt charged for some installs that happened during that time, because my attribution system was dependent on that method.

    I have now fixed it and wrote my own Android Library for obtaining advertisement ID, but my attribution system is now sort of penalized because for few hours I wasnt sending postbacks on installs, and now my campaign gets 0 views.

    @kyle-unity can I have a call with someone regarding that, so I can show that it is working properly and get a penalty removed. It was just a bad coinsidence.
     
  8. kyle-unity

    kyle-unity

    Unity Technologies

    Joined:
    Jan 6, 2020
    Posts:
    336
    @SamTyurenkov I'm a bit confused. Are you saying your traffic has dropped to 0 because of the lack of installs?

    Situations like that aren't a penalty, per se, it's just that the time period where we weren't seeing install postbacks will have affected our algorithm's eCPM estimate for your campaigns, and therefore your previous bid amount is no longer competitive against other apps on our network.

    The fix is to temporarily boost your campaign bid amounts to get the traffic flowing again. Once we start receiving install postbacks again our eCPM estimates will adjust and you can lower the bid amount back down to a level you are happy with. Unfortunately, Unity staff aren't able to manually adjust campaign performance.
     
    SamTyurenkov likes this.
  9. luktus

    luktus

    Joined:
    Nov 28, 2013
    Posts:
    7
    ilievant and Novack like this.
  10. esaffer

    esaffer

    Joined:
    Oct 26, 2014
    Posts:
    3
    Is this still working? I am trying to use and get some id. But, when I try to get an id where the user's google account has ads settings defined as "not personalized", it stills return a random number. My current theory is that it should work only at Android 12 devices...
     
  11. lucbloom

    lucbloom

    Joined:
    Mar 27, 2020
    Posts:
    32
    Just call the Java code directly:
    Code (CSharp):
    1.         public static string GetAndroidAdvertiserId()
    2.         {
    3.             string advertisingID = "";
    4.             try
    5.             {
    6.                 AndroidJavaClass up = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
    7.                 AndroidJavaObject currentActivity = up.GetStatic<AndroidJavaObject> ("currentActivity");
    8.                 AndroidJavaClass client = new AndroidJavaClass ("com.google.android.gms.ads.identifier.AdvertisingIdClient");
    9.                 AndroidJavaObject adInfo = client.CallStatic<AndroidJavaObject> ("getAdvertisingIdInfo", currentActivity);
    10.      
    11.                 advertisingID = adInfo.Call<string> ("getId").ToString();
    12.             }
    13.             catch (Exception)
    14.             {
    15.             }
    16.             return advertisingID;
    17.         }
     
    ilievant likes this.