Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Ad Tracking and IDFA Docs? #53

Open
b099l3 opened this issue Aug 12, 2022 · 2 comments
Open

Request: Ad Tracking and IDFA Docs? #53

b099l3 opened this issue Aug 12, 2022 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@b099l3
Copy link
Contributor

b099l3 commented Aug 12, 2022

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?

@danielgomezrico danielgomezrico added the help wanted Extra attention is needed label Aug 20, 2022
@danielgomezrico
Copy link
Contributor

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!

@brunapcat
Copy link

Hello,

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants