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, or IDFA in iOS, you can add the AdSupport framework to your project and use the code snippet like below after you have initialized the Plot Plugin.

#import <AdSupport/ASIdentifierManager.h>

[Plot setAdvertisingIdentifier:[[ASIdentifierManager sharedManager] advertisingIdentifier] advertisingTrackingEnabled:[[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]];

Your app must comply with IDFA usage in order to be listed in the App Store. More information can be found at the App Store Connect - Submit for review.

iOS 14

With the release of iOS 14, the IDFA is not accessible by default. You will need to request permission to be able to access the IDFA.

Request IDFA

When targeting iOS 14, you need to use AppTrackingTransparency and AdSupport frameworks. You need to link them in your project settings.

First you need to update your Info.plist file to include the following key with a description about the purpose of tracking IDFA. That description will show in the permission request dialog user will see.

// Privacy - Tracking Usage Description
<key>NSUserTrackingUsageDescription</key>
<string>App would like to access your IDFA</string>

After that, you need to execute the actual request.

IDFA request
Objective-C
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/AdSupport.h>

[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
    if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
        [Plot setAdvertisingIdentifier:[[ASIdentifierManager sharedManager] advertisingIdentifier]
            advertisingTrackingEnabled:[[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]];
    }
}];
Swift
import AdSupport
import AppTrackingTransparency

func requestPermission() {
    ATTrackingManager.requestTrackingAuthorization { status in
        switch status {
            case .authorized:
                print("Authorized")
            case .denied:
                print("Denied")
            case .notDetermined:
                print("Not Determined")
            case .restricted:
                print("Restricted")
            @unknown default:
                print("Unknown")
        }
    }
}

For more information on IDFA changes look into the official iOS documentation.