Skip to main content

Callbacks

Attribution callbacks

You can register a delegate callback to notify you of tracker attribution changes. The Adtrace SDK cannot provide this information synchronously. This is due to the different sources considered for attribution.

Follow the steps in this article to implement the optional delegate protocol in your app.

Important

To set up the delegate callback, you need to configure it in your ADJConfig instance. This means you will need to add the setDelegate call before you call the appDidLaunch method.

  1. If you are not using web views, add the AdtraceDelegate declaration to your AppDelegate header file.

In your AppDelegate.h file:

@interface AppDelegate : UIResponder <UIApplicationDelegate, AdtraceDelegate>
  1. If you are not using web views, add the delegate callback function to your app delegate implementation.

In your AppDelegate.h file:

- (void)adtraceAttributionChanged:(ADJAttribution *)attribution {
// ...
}
  1. Set the delegate with your Adtrace config instance.

In your AppDelegate.h file:

[adtraceConfig setDelegate:self];

The SDK will call the delegate function after receiving its final attribution data. Within the delegate function, you will have access to the attribution object.

All properties are returned as a JSON object. Any values that are not populated will be sent back as nil.

ValuesData typeDescription
trackerTokenStringThe token of the tracker to which the device is currently attributed.
trackerNameStringThe name of the tracker to which the device is currently attributed.
networkStringThe name of the network to which the device is currently attributed.
campaignStringThe name of the campaign to which the device is currently attributed.
adgroupStringThe name of the adgroup to which the device is currently attributed.
creativeStringThe name of the creative to which the device is currently attributed.
adidStringThe unique Adtrace ID assigned to the device.

Event and session callbacks

You can register a delegate callback to notify you of the status of event and session tracking. The Adtrace SDK uses the optional AdtraceDelegate protocol used for the attribution callback.

Add the following delegate callback function for successfully tracked events:

- (void)adtraceEventTrackingSucceeded:(ADJEventSuccess *)eventSuccessResponseData {
// ...
}

Add the following delegate callback function for failed tracked events:

- (void)adtraceEventTrackingFailed:(ADJEventFailure *)eventFailureResponseData {
// ...
}

Add the following delegate callback function for successfully tracked sessions:

- (void)adtraceSessionTrackingSucceeded:(ADJSessionSuccess *)sessionSuccessResponseData {
// ...
}

Add the following delegate callback function for failed tracked sessions:

- (void)adtraceSessionTrackingFailed:(ADJSessionFailure *)sessionFailureResponseData {
// ...
}

The SDK will call the delegate functions after it tries to send a package to the Adtrace backend. You have access to a response data object within the delegate callback. This object contains information about the status of the callback. Here is a summary of the returned properties:

Event Parameters
PropertyData typeDescription
messageNSStringThe message from the server or the error logged by the SDK.
timeStampNSStringThe timestamp from the Adtrace backend.
adidNSStringA unique device identifier provided by Adtrace.
jsonResponseNSDictionaryThe JSON object with the response from the server.
eventTokenNSStringThe event token.
callbackIdNSStringThe custom defined callback ID set on event object.
willRetryBOOLReturned if the event object failed. Indicates whether there will be an attempt to resend the package at a later time.
Session Parameters
PropertyData typeDescription
messageNSStringThe message from the server or the error logged by the SDK.
timeStampNSStringThe timestamp from the Adtrace backend.
adidNSStringA unique device identifier provided by Adtrace.
jsonResponseNSDictionaryThe JSON object with the response from the server.
willRetryBOOLReturned if the session object failed. Indicates whether there will be an attempt to resend the package at a later time.