ESPs (Email Service Providers) can be excellent sources for segmented user traffic.
One of the problems with ESPs is tracking clicks while still persevering deep linking functionality. ESPs wrap the deep linking URL with their own ESP's click tracking domain. This procedure often times breaks the iOS Universal Links process.
However, with ESPs that support Universal Links on top of their click tracking domain, deep linking and click tracking can still be performed.
This article explains the flow for integrating OneLink-based tracking links into your Sendgrid based email system in order to seamlessly deep link from emails. The integration utilizes Sendgrid’s support for Universal Links on top of the branded click tracking domain.
- AppsFlyer iOS SDK version 4.9.0
- AppsFlyer Android SDK version 4.9.0
SendGrid doesn’t support Android App Links. However, URI Scheme deep linking is still supported. No special actions are required to support deep linking in Android apps from SendGrid.
Setting Up SendGrid
Step 1 - Set up Link Branding in SendGrid
In order to use Universal Links with SendGrid, you need to create a dedicated click tracking domain (e.g. click.example.com). This can be done by purchasing a designated domain or using your own domain. For more information, refer to SendGrid documentation on Setting Up Link Branding.
Step 2 - Set up SSL for click tracking
After you set click tracking domain and Link Branding, follow SendGrid's instructions on how to enable SSL click and open tracking for an authenticated domain.
Step 3 - Apple App Site Association File (AASA) Hosting
- Contact your AppsFlyer CSM to generate an AASA file for SendGrid Universal Link usage. Provide the click tracking URL (e.g. click.example.com), and the OneLink ID that you use for creating OneLink Tracking Links within your emails.
- Host the AASA in your click tracking domain server. The file should be hosted in the path: click.example.com/apple-app-site-association.
Once the AASA file is hosted, any change of your OneLink configuration (either modification or replacement) requires generating new AASA file.
Step 4 - Configuring your AppsFlyer SDK
If you haven’t already done so, make sure you have configured your app to support deep linking with OneLink.
After configuring your click tracking domain to support Universal Links as described previously, you will need to set up your app to deep link and resolve that Universal Link.
- Associate the click tracking domain in Xcode:
- Provide the click tracking domain to the SDK API
setResolveDeepLinkURLs. This API needs to be called before SDK initialization. For more information please refer to SDK documentation here.
[[AppsFlyerTracker sharedTracker] setResolveDeepLinkURLs:@[@"click.example.com"]];
- When the app is invoked due to a click on the Universal Link, the AppsFlyer SDK resolves the deep link and extracts the underlying OneLink. All deep link parameters are then propagated into the onAppOpenAttribution API for deep link logic execution.
Step 5 - Sending Your First Email
- Create a OneLink URL in the Link Management page (or manually)
- When creating the OneLink URL make sure to URL encode all parameter values
- The following parameters are highly recommended to use:
- pid (media source) - Use a media source that signifies this usage such as Email.
- c (campaign) - The name of the campaign you want to track
- 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 in an iOS device
- af_android_url - Where to redirect users that don’t have the app click the link in an Android device
- Place this link in the email you are creating in SendGrid's Code Editor or Design Editor.
At this stage, SendGrid wraps the above link with your click tracking domain that you set in the previous steps. Any click on the click tracking domain will redirect to the OneLink tracking link.
URL parameters are not URL encoded for the sake of readability:
https://example.onelink.me/ABcd?pid=Email&c=Spring_Newsletter& af_dp=testapp://path/to/content&af_web_dp=https://www.example.com/path/to/content& af_ios_url=https://www.example.com/path/to/content&af_android_url=https://www.example.com/path/to/content
Step 6 - Testing Your Links
After following all the required steps mentioned above, creating the appropriate OneLink URL, and placing it in an email, send yourself a test email.
What should you expect?
If you have the app installed, the app should be invoked. If the relevant AppsFlyer SDK deep linking APIs are implemented you should be deep linked into the relevant content.
In addition, a click should appear in both the AppsFlyer dashboard, attributed to the provided media source and campaign, and also in SendGrid's data