At a glance: Set up OneLink Smart Script to convert and attribute your mobile website visitors, coming from any source, into mobile app users. Note: Although not mandatory, consider migrating to OneLink Smart Script V2.
Setup
There are two versions of OneLink Smart Script:
OneLink Smart Script V2 (recommended): If you are setting up OneLink Smart Script for the first time, this is the preferred version to use. The developer work portion is easier, and it can also be set up using Google Tag Manager. Note: Although not mandatory, consider migrating to V2.
OneLink Smart Script V1 (legacy): If you already have Onelink Smart Script set up, use the documentation for this version to maintain and edit this script.
Responsibilities
Who's involved
|
Prerequisites
|
To implement the script on the web page:
- Decide what parameters/values the automatically-generated outgoing OneLink URL should contain. See the list of parameters you can use.
- Make sure that all campaigns with incoming URLs have parameters that the script works for (and can place as the pid and c parameters).
- Provide the list of parameters to the web developer.
- Tell the developer to follow the dev instructions and implement the script so the correct outgoing link is generated.
Parameters
Parameters/values provided to the developer to implement the Smart Script
Param/value | Remarks | Record your responses (for the developer to use) |
---|---|---|
oneLinkURL (required) |
|
|
pidKeysList (media sources) |
|
|
pidOverrideList |
|
|
pidStaticValue |
|
|
campaignKeysList (campaigns) |
|
|
campaignStaticValue |
|
|
gclIdParam |
|
|
skipList |
|
|
Other query parameters |
|
Use cases
The following sections provide Smart Script use cases for some common campaign/media source scenarios.
Meta ads—cross-platform attribution
Meta ads is an SRN that doesn't use external attribution links.
Upon first app launch, AppsFlyer queries Meta ads whether the user has previously (within the last 7 days) engaged with an ad for the app. If the user has engaged with a Facebook ad of the advertiser, Meta ads self-attributes. Meta ads also attributes cross-platform, meaning that the user may interact with any type of campaign, mobile or not, on any platform, to be self-attributed by Meta ads.
Action: Tell your developer to use the skipList method to disable the Smart Script for Meta ads (or any other strings you want). If Meta ads or any of the strings in the skip list appear in the HTTP referrer of the click, the Smart Script returns null
.
Note: Meta ads cross-platform attribution may be affected when users opt not to share their device ID, as is expected with iOS 14 users during 2021.
Google Ads—GCLID and UTM parameters
The usual process for install attribution of Google Ads campaigns (which carry a GCLID parameter) requires clicking leads to be redirected to the app's store page URL.
Since in this case, you are redirecting leads from Google Ads to a web/landing page, the script takes the GCLID parameter from the Google Ads install campaign URL and puts it into the outgoing URL in your choice of output parameter af_sub[1-5]. Note! This applies to install campaigns. For non-ACI search campaigns, meaning re-engagement campaigns, Google may be attributed as the media source, despite the Smart Script output.
Prerequisite: On the Google dashboard, enable auto-tagging.
With auto-tagging enabled, the URL contains the GCLID parameter.
To set up the script for Google Ads:
- Make a list of the media source and campaign parameter names that are in the incoming links.
For example: utm_source and utm_campaign. - Select a parameter in the outgoing URL to contain the GCLID.
Best practice: Select af_sub[1-5], so that the data displays in AppsFlyer raw data reports. -
Provide these in the list of parameters to the web developer.
Result:
- The values in the media source and campaign parameters (utm_source and utm_campaign) in the incoming link are used to populate the values for the pid and c parameters in the outgoing link.
- In the outgoing URL, the GCLID is the value of the af_sub[1-5] param.
To notify Google Ads about these installs:
- Get the GCLID data from the param af_sub[1-5] via CSV, or Push API in real-time for every install.
- Upload the GCLID data to Google either manually or via an Adwords API.
Note
This GCLID solution is not officially supported or recommended by Google. In case Google deprecates the GCLID parameter we will change the script to support the changes. Follow this article, by clicking the Follow button in the article header, to get informed when there is an update to the article or attached script.
SRNs, owned media, and other media source links
SRNs like Snapchat or X Ads, work differently than Google Ads or a cross-platform like Meta ads. Campaigns from these SRNs lead your users to the web/landing page, and you are billed according to clicking leads, unrelated to any derived mobile users.
For these SRNs, script setup is the same as for links from owned media, or other media sources you might use.
To set up the script:
- Make a list of the media source and campaign parameter names that are in the incoming links.
-
Provide these in the list of parameters to the web developer.
The SRN/media source type should be the media source value in the incoming URL, and the script finds it and uses it as the pid value in the outgoing OneLink URL behind the download button on the web/landing page. If you want to change the outgoing pid, provide the incoming media source value and the replacement pid value in the pid override list.
Result: For these SRNs/media sources, the values in the media source and campaign parameters in the incoming link are used to populate the values for the pid and c parameters in the outgoing link.
Example
Incoming URL: https://hotel.me/af_pid=twitter&af_c=big_social
Outgoing URL: https://hotel.onelink.me/Ac4G?pid=twitter&c=big_social
AppsFlyer attribution links
AppsFlyer attribution links can be used when the media source is a click ad network. When you set up such a link in AppsFlyer, you have the option to add a Redirection URL path (af_r) parameter with the desired URL path to your mobile website, for web campaign-to-app attribution.
Result: If the af_r and af_redirect=true parameters are on the incoming link, the landing page script makes no changes. It leaves the web/landing page direct links to the app stores as they are.
Example
Incoming URL: https://app.appsflyer.com/id123456789?pid=click_ad_network_int&c=orlando&af_redirect=true&af_r=hotel.me
Outgoing URL: Same
Desktop
Most use cases in this article are of users coming from mobile devices. Therefore, when directed from the mobile website to an app store, they can immediately download your app.
However, desktop users shouldn't immediately be sent to an app store, because their device (a desktop or laptop) isn't compatible with mobile app downloads.
To set up the script for desktop users:
- In your OneLink template, set a destination URL for When link is clicked on desktop. The URL should redirect to a dedicated web/landing page. The landing page can contain a web form where they fill in their details to get an SMS or an email with a link to download the app. It's up to you to create the web form and provide the URL to it in the script.
Result: The script detects the device or platform the user is on. If it's desktop, the script generates an outgoing OneLink URL that redirects the user to your dedicated web/landing page.
See also Desktop-to-app conversion.
Limitations
Limitation | Remarks |
---|---|
Tag manager |
Smart Script cannot be implemented via tag manager. See OneLink Smart Script V2 or Smart Banners as an alternative web-to-app attribution solution. |