At a glance: Learn how to embed AppsFlyer OneLink in SparkPost, an email delivery and analytics platform.
Email service providers (ESPs) are excellent sources of segmented user traffic. They wrap deep linking URLs with their own click recording domain. In some cases doing so breaks iOS Universal Links. To overcome this, SparkPost uses Universal Links on top of their click recording domain. They integrate with AppsFlyer and by using OneLink capabilities enable deep linking and click recording.
Setting up SparkPost
Configure SparkPost and the AppsFlyer SDK, to send emails containing OneLinks.
For additional information on setting up SparkPost, reach out to SparkPost support.
Mobile SDK versions:
- iOS: V6.0.4 or later
- Android V6.0.0 or later
Step 1: Setting in SparkPost
Create a dedicated click tracking domain and set a subdomain.
Set up sending domains and click-tracking domains, and enable HTTP engagement tracking.
Related reading getting started with SparkPost.
To set up domains and HTTP engagement tracking:
- Open your SparkPost dashboard.
- Go to Configuration > Sending Domains.
- Click Add a Domain.
- Follow the instructions in the user interface.
- Go to Configuration > Tracking Domains.
- Click Create Tracking Domain.
- Follow the instructions in the user interface.
- To enable HTTPS engagement tracking: Follow SparkPost instructions about enabling SSL for the tracking domain.
Step 2: AASA hosting and custom link sub-path setup
For SparkPost to support iOS Universal Links, you need to upload an AASA file onto it.
When you set up OneLink with Universal Links, you already have an AASA associated with the OneLink. To get the AASA:
- In AppsFlyer, go to OneLink templates.
- Copy a OneLink that is configured with Universal Links.
- Add /.well-known/apple-app-site-association to the end of the OneLink URL.
- Paste the OneLink in the browser address bar, then <enter>.
The AASA file downloads to your computer.
- Follow SparkPost guide on how to configure Universal Links and create custom link sub-path.
- Host the AASA in your click recording domain server in SparkPost. Host the file in the path: click.example.com/.well-known/apple-app-site-association.
- After the click tracking domain is verified:
- Delete the cname definition (example: example click -> spgo.io).
- Cname your click tracking domain to your CDN (where the AASA file is located).
Once the AASA file is hosted, any modification or replacement of your OneLink configuration requires generating a new AASA file.
Step 3: Configure AppsFlyer SDK
Before configuring the AppsFlyer SDK, configure the app to support deep linking with OneLink.
Associate click recording domain in Xcode
- In Xcode, select your project.
- Select Capabilities.
- Turn on Associated Domains.
- Click + (plus), enter your click domain. For example, applinks:click.example.com.
Resolve deep links
To get campaign details, the SDK needs to resolve the OneLink behind the click domain. The details are returned in the
To resolve click domains:
- List the click domains in the SDK property
Make sure to set this property before SDK initialization.
- Define spgo.io as part of resolving deeplink API.
SparkPost owns this domain and its part of the redirection flow.
AppsFlyerLib.shared().resolveDeepLinkURLs = [“click.example.com”,“spgo.io”]
When a click on the Universal Link occurs, the app is invoked. AppsFlyer SDK resolves the deep link and extracts the underlying OneLink. Then, all deep link parameters are propagated into the
onAppOpenAttribution API for deep link logic execution.
Learn more about resolving wrapped deep link URLs.
Send emails with OneLink through SparkPost
- Create a OneLink URL on the Link Management page (or manually). You must URL-encode parameter values.
- [Best practice] Use the following parameters:
- pid (media source): Use a media source that signifies this usage such as Email.
- c (campaign): Campaign name
- af_dp: The deep link URI scheme you want to deep-link your users into.
- af_web_dp: Where to redirect users clicking the link on desktop.
- af_ios_url: Where to redirect users that don’t have the app clicking the link on an iOS device.
- af_android_url: Where to redirect users that don’t have the app click the link on an Android device.
- Insert the OneLink URL in the email created using the SparkPost Code Editor or Design Editor. Example:
<a href="links.example.com data-msys-sublink="appsflyer">Link to your app!</a>
- If the email is part of a retargeting campaign, add the parameter is_retargeting=true.
This indicates that the attribution link is from a retargeting campaign. Learn more about retargeting.
- SparkPost wraps the link with the defined click domain so that a click on the click domain redirects to the OneLink attribution link.
The URL parameters in the example that follows aren't encoded to enable ease of reading.
Test your links
To test the integration:
- Set-up SparkPost.
- Create a OneLink URL.
- Insert the URL in an email.
- Send a test email to yourself.
- If you have the app installed, it should launch and you will be deep-linked into the defined app page.
- A click reflects in:
- The AppsFlyer dashboard, attributed to the media source and campaign.
- SparkPost data.