Skip to content

Axon Pixel Mobile App Integration

This guide shows how to integrate the Axon SDK into your native iOS mobile app so that you can track events for that app.

Download the Latest SDK

You can download the SDK through CocoaPods as a dependency.

The SDK requires the minimum iOS deployment target to be iOS 12.0 or above. It also requires Xcode version 15 or above.

To integrate the AxonSDK through CocoaPods:

  1. Add the following line to your Podfile:

    pod 'AxonSDK'
  2. Run the following on the command line:

    Terminal window
    pod install --repo-update

Initialize the SDK

Initialize the AxonSDK with the event key at startup to maximize how long the SDK can take to ready core services. Replace “«your-event-key»” with your Axon Event Key.

You can find your Axon Event Key in the Account > General > Keys section of the AppLovin dashboard.

import AxonSDK
Axon.shared.initialize(withKey: "«your-event-key»") {
}

You must provide a deep link so that when a user clicks an ad, either your app seamlessly opens if it is installed, or the click routes them to a browser otherwise. In your app delegate, call Axon SDK’s processDeepLink: API to handle inbound deep links and associated metadata.

func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool
{
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL else
{
return true
}
// Pass deep link URL to Axon SDK in order to potentially reattribute the user
Axon.shared.processDeepLink(url)
return true
}

Tracking Events with the Axon SDK

To send an occurrence of an ecommerce event to Axon, use the following syntax. Each event should trigger when its corresponding event happens in the data layer.

sdk.eventService.track(event: «event-name», parameters: «event-data»)

Parameters

NameTypeDescription
event_namestringThe name for this event. See Axon Pixel Events and Objects for available events.
event_dataobjectThe data for this event. See Axon Pixel Events and Objects for data to send. (Note: you do not need to send event_data with page_view.)

All events require the event_name argument. Each event except for page_view also requires certain event_data, described in the event-specific sections below.

Passing Data to the Axon SDK

For each of the events that requires event_data, AppLovin recommends that you create a dictionary that is the payload. For example:

sdk.eventService.track(event: "add_to_cart", parameters: [
"currency" : "USD",
"value" : 99.99,
"items" : [
]
])