flutter-segment icon indicating copy to clipboard operation
flutter-segment copied to clipboard

Request: Ad Tracking and IDFA Docs?

Open b099l3 opened this issue 3 years ago • 2 comments

I see this package is using analytics-ios 4.1.6

When trying to set up Ad Tracking and IDFA I noticed the official docs has some setup steps with analytics-ios 4.1 or greater:

Starting iOS 14, applications must prompt users if that app needs to collect their Identifier for Advertisers (IDFA). Going forward with analytics-ios-4.1 and later, Segment doesn’t auto-collect IDFA. If your app or any integrations require the use of IDFA, you need to:

  1. import the AdSupport and App Tracking Transparency Frameworks by Apple
  2. pass the below code snippet to Segment config and start tracking events
  3. prompt the user for consent and collect the IDFA You can use the following closure snippet to pass the value to analytics-ios as configurations:
@import AdSupport;

...

SEGAnalyticsConfiguration* configuration = [SEGAnalyticsConfiguration configurationWithWriteKey:@"YOUR_WRITE_KEY"];
// Enable advertising collection
configuration.enableAdvertisingTracking = YES;
// Set the block to be called when the advertisingID is needed
// NOTE: In iOS 14, you'll need to manually do authorization elsewhere and only when it has been authorized, return the advertisingIdentifier to segment via the block below
configuration.adSupportBlock = ^{
    return [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
};
[SEGAnalytics setupWithConfiguration:configuration];

Or the option of setting two keys under the context object:

Ad-tracking affects two keys under the context object of every event:

device.adTrackingEnabled true if SDK is setup with closure and user has consented, false otherwise
device.advertisingId idfa_value if user opts-in otherwise this key is skipped from event payload

I did this using the second option of adding to the context object, with the IDFA which I got from using this package:

final advertisingId = await getAdvertisingId();
final adTrackingEnabled = await getadTrackingEnabled();

Segment.setContext({
  'device': {
    'adTrackingEnabled': adTrackingEnabled.toString(),
    'advertisingId': advertisingId,
  }
});

I wonder if we should add some docs for setting up Ad Tracking and IDFA on iOS? I can do it just want to make sure this is something we want on this repo?

b099l3 avatar Aug 12 '22 16:08 b099l3

Hi @b099l3

Thanks for opening the issue, If that feature is already working and you found a way to do it feel free to add docs for it :) sure!

danielgomezrico avatar Aug 20 '22 15:08 danielgomezrico

Hello,

Are there any updates abot setting up Ad Tracking and IDFA on iOS?

brunapcat avatar Oct 14 '22 14:10 brunapcat