Skip to main content

Get attribution information

When a user interacts with an Adtrace tracker link or a deep link, their attribution information can update. Attribution details are represented by the ADTAttribution class.

Use this guide to:

  1. Read the current attribution with [Adtrace attribution] / Adtrace.attribution().
  2. Run code when attribution changes with adtraceAttributionChanged: on AdtraceDelegate.

ADTAttribution properties

The ADTAttribution class holds the current attribution status for the device. Any value that is not set for the user is returned as nil.

PropertyTypeDescription
trackerTokenNSStringToken of the tracker the device is currently attributed to.
trackerNameNSStringName of the tracker the device is currently attributed to.
networkNSStringNetwork the device is currently attributed to.
campaignNSStringCampaign the device is currently attributed to.
adgroupNSStringAd group the device is currently attributed to.
creativeNSStringCreative the device is currently attributed to.
clickLabelNSStringClick label tagged on the install.
adidNSStringUnique Adtrace device identifier.
costTypeNSStringCampaign pricing model (for example cpi). Requires cost data in attribution.
costAmountNSNumberCost of the install. Requires cost data in attribution.
costCurrencyNSStringISO 4217 currency code for the cost. Requires cost data in attribution.
tip

Cost fields are only available when you enable them with setNeedsCost: on ADTConfig before appDidLaunch. If cost is not enabled or not part of the attribution, these fields are nil. Available in SDK v2.0.5+.

Get current attribution information

Access the user's current attribution whenever you need it by calling attribution on Adtrace.

Method signature

+ (nullable ADTAttribution *)attribution;

When a user installs your app, Adtrace attributes the install to a campaign. Call attribution to read the current attribution as an ADTAttribution object.

Important

Current attribution is only available after Adtrace tracks the app install and the attribution callback has been triggered at least once. You cannot access attribution before the SDK is initialized and that callback has run.

Example

ADTAttribution *attribution = [Adtrace attribution];
NSLog(@"Tracker token: %@", attribution.trackerToken);

Then read fields from the returned object (for example attribution.trackerToken, attribution.campaign).

The attribution callback is also triggered whenever attribution changes, including after re-engagement deep links.

Trigger a function when attribution changes

Like the on-demand attribution call, the SDK can notify you whenever attribution information changes. Register an AdtraceDelegate on your ADTConfig instance before appDidLaunch.

Attribution can come from different sources, so this information is not available synchronously at init time. The delegate method runs after the SDK receives updated attribution data.

Delegate method

- (void)adtraceAttributionChanged:(nullable ADTAttribution *)attribution;
ParameterTypeDescription
attributionADTAttributionCurrent attribution data after a change.
Important

Call setDelegate: on ADTConfig before you initialize the SDK with appDidLaunch. See Send callback information for full delegate setup.

Example

AppDelegate.m
[adtraceConfig setDelegate:self];

- (void)adtraceAttributionChanged:(ADTAttribution *)attribution {
NSLog(@"Tracker token: %@", attribution.trackerToken);
NSLog(@"Campaign: %@", attribution.campaign);
}

See Configuration for how to create the ADTConfig instance.