Advertising identifier - How to get started

The Plot Plugin makes it possible to offer better targeted advertisements and improved extensive segmented reporting by looking at the user's behavior in other apps by correlating using an Advertising Identifier, often called as IDFA on iOS and Advertising ID on Android.

The Advertising Identifier can be set in the Plot Plugin version 1.10.0 and higher. The advantage for the end user is that it allows more relevant notifications in the future. Both on iOS and on Android have a standardized mechanism that allows collecting information about the user in a non-intrusive way. It is not required to make use of the Advertising Identifier to segment your users. Read more about that in Segmentation - How to get started.

Note

On both iOS and Android, it is possible for end-users to opt-out from the Advertising Identifier. In iOS this functionality is available since version 6 and on Android this is part of Google Play Services version 4.0

We store the Advertising Identifier when the identifier is shared with us as explained in this guide and the end-user has not opted-out. We combine this identifier with the notifications they have received and opened, and with their segmentation values.

To make use of an Advertising Identifier, often abbreviated as Advertising ID in Android, you can use the Google Play Services ads identifier library and use the code snippet like below after you have initialized the Plot Plugin.

import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.plotprojects.retail.android.Plot;
import com.google.common.util.concurrent.Futures;

// Do not call this function from the main thread. Otherwise, 
// an IllegalStateException will be thrown.
public void setAdvertisingId() {
  if (AdvertisingIdClient.isAdvertisingIdProviderAvailable()) {
            ListenableFuture<AdvertisingIdInfo> advertisingIdInfoListenableFuture =
                    AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext());
            Futures.addCallback(advertisingIdInfoListenableFuture,
                    new FutureCallback<AdvertisingIdInfo>() {
                        @Override
                        public void onSuccess(AdvertisingIdInfo adInfo) {
                            String advertisingId = adInfo.getId();
                            String providerPackageName =
                                    adInfo.getProviderPackageName();
                            boolean limitAdTracking =
                                    adInfo.isLimitTrackingEnabled();

                            Plot.setAdvertisingId(advertisingId, limitAdTracking);

                        }
                        // Any exceptions thrown by getAdvertisingIdInfo()
                        // cause this method to get called.
                        @Override
                        public void onFailure(Throwable throwable) {
                            Log.e("MY_APP_TAG",
                                    "Failed to connect to Advertising ID provider.");
                            // Try to connect to the Advertising ID provider again,
                            // or fall back to an ads solution that doesn't require
                            // using the Advertising ID library.
                        }
                    });
        } else {
            // The Advertising ID client library is unavailable. Use a different
            // library to perform any required ads use cases.
        }
}

For more information about getting advertising identifier in Android, please refer to Android's developers guide.

Google has an usage policy for when using the Advertising ID. The app has to comply with the policy for it to be allowed in the Play Store.