OneLink Smart Script —Web-to-app URL generator

At a glance: Use OneLink Smart Script to generate URLs. The URLs are embedded behind a button on your mobile website which redirects visitors to download your app. The URLs also support install attribution and deep linking. 

6131_Smart_Script_flow_750x420_KB1.png

 News

This version provides improved functionality and is easier to implement than the previous mobile landing page attribution script. If you are still using the previous script, you should migrate. 

About OneLink Smart Script

Users arrive at your mobile website before reaching your app store page, either organically, or after engaging with advertising campaigns. However, there are two clicks as follows:

  • Direct to the web page
  • Direct from the web page to the app store

In this scenario attribution and deep linking are problematic. Installs by users who eventually download the app may be wrongfully attributed, or attributed as organic. This can occur even if the first click comes from an ad network, Google click, or owned media source. 

OneLink Smart Script solves these problems in that it:

  • Uses the incoming URLs leading to the webpage to dynamically generate unique outgoing OneLink URLs leading to the app store. 
  • Provides accurate web-to-app attribution for all media sources, including ad networks, SRNs, Google clicks, and owned media. 
  • Can be used for deep linking.
  • Runs seamlessly on any webpage or landing page. 
  • Doesn't require the use of Smart Banners. 
    Note: Smart Banners can be a great conversion tool for many verticals and do not require a developer to set up, but they add another step, the banner, to the user journey.

 Note

Not sure whether OneLink Smart Script is the right solution for you?
Compare OneLink Smart Script with other AppsFlyer web-to-app solutions.

Examples

The examples in this section demonstrate how OneLink Smart Script is used to generate outgoing OneLink URLs that provide accurate attribution, or deep linking functionality. For use cases of campaign types with particular media sources, see Use cases

Attribution

Mark is the marketer for a hotel chain. He sends an email advertising a hotel vacation in Orlando, Florida. The link in the email looks like this: https://hotel.me/pid=email&c=orlando

The link redirects users to the hotel’s mobile web site. There, users see buttons inviting them to download the hotel’s mobile app. The OneLink Smart Script automatically generates a URL that contains the same pid and c parameters as the original link in the email. The link looks like this: https://hotel.onelink.me/Ac4G?pid=email&c=orlando

When users click the buttons on the mobile site to download the app, the app install is attributed to Mark’s Orlando email campaign.

Deep linking

Emma gets an email advertising a hotel vacation in Orlando, Florida.

The link in the email looks like this: https://hotel.me?type=email&campaign=Florida&city=orlando

When she clicks the link, it redirects her to the hotel’s mobile web site. There, she see buttons inviting her to download the hotel’s mobile app. The OneLink Smart Script automatically generates a URL that contains the same pid and c parameters as the original link in the email. The link looks like this: https://hotel.onelink.me/Ac4G?pid=email&c=Florida&deep_link_value=orlando

When Emma clicks the buttons on the mobile site, she is redirected to the app store. And when she downloads and launches the app, she is deep linked to the Orlando vacation page in the app.

 Note

The deep linking is in accordance with the app settings implemented by the app developers. Learn more

Setup

Responsibilities

Who's involved

  • Advertiser: 
    • Decides what the outgoing URL should contain. This includes what attribution data to append to the link, and data required for deep linking. Either by manipulating the incoming URL or by forcing certain values. 

    • Makes sure all campaigns leading to the mobile website have incoming URLs with parameters that the script works for. 
  • Web developer:
    • Configures the data to initialize the script. 
    • Enters the setters necessary to generate the outgoing OneLink URLs based on the incoming URL parameters.  
    • Embeds the script in the website or specific page/s. 

Prerequisites

To implement the script on the webpage:

  1. 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). 
  2. Provide the list of parameters to the web developer.
  3. Tell the developer to follow the dev instructions and implement the script.

Parameters

Param/value Remarks Your response (for the developer to use)
oneLinkURL (required)
  • Provide the OneLink base URL, meaning the OneLink template domain + template ID.
  • Example: yourbrand.onelink.me/1a6f
  • Branded domain example: yourbrand.com/1a6f
 
pidKeysList (media sources)
  • List all the media source parameter/s in the incoming URL that will be placed as the media source (pid) parameter in the outgoing URL.
  • Example: ['af_pid', 'utm_source']
 

pidOverrideList

  • For media sources you want changed in the outgoing link, list the media source values in the incoming URL, alongside what you want them to be replaced with.
  • Example: {
    'twitter': 'twitter_int',
    'snapchat': 'snapchat_int',
    'some_social_net': 'some_social_net_int'
    }

 

pidStaticValue

  • State what you want your "fallback" media source to be.
  • If a media source parameter is not found in your pidKeysList, the pidStaticValue is used as the media source (pid) in the outgoing URL.
  • Example: 'website' or 'organic'

 

campaignKeysList (campaigns)
  • List all the campaign parameter/s in the incoming URL that will be placed as the campaign (c) parameter in the outgoing URL.
  • Example: ['af_campaign', 'utm_campaign']

 

campaignStaticValue
  • State what you want your "fallback" campaign to be.
  • If a campaign parameter is not found in your campaignKeysList, the campaignStaticValue is used as the campaign (c) in the outgoing URL.
  • Example: 'website' or 'organic'

 

gclIdParam
  • State what to call the parameter that carries the GCLID.
    Note! To display in AppsFlyer raw data reports, the param must be one of af_sub[1-5].
 
Other query parameters
  • List any other parameters you want to be included in the outgoing OneLink URL for attribution or deep linking.
  • Add a deep_link_value for deep linking.
    • In addition to adding the param, you and your developer need to implement the deep linking logic. Learn more 
  • You can either use parameters from the incoming URL, or force a static value. 
 
Parameters/values provided to the developer to implement the Smart Script

Use cases

The following sections provide Smart Script use cases for some common campaign/media source scenarios.

Facebook Adscross-platform attribution

Facebook is an SRN that doesn't use external attribution links.

Upon first app launch, AppsFlyer queries Facebook whether the user has previously (within the last 28 days) engaged with an ad for the app. If the user has engaged with a Facebook ad of the advertiser, Facebook self-attributes. Facebook 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 Facebook.

Result: The landing page script makes no changes. The script is designed to detect a user coming from Facebook. If it does, it doesn't do anything. It leaves the web/landing page direct links to the app stores as they are. This prevents another click from being recorded which could affect CTR.

Note: Facebook's 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 AdsGCLID 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 campaign URL and puts it into the outgoing URL in an output parameter of your choice. Note! To display in AppsFlyer raw data reports, the param must be one of af_sub[1-5].

To set up the script for Google Ads:

  1. Make a list of the media source and campaign parameter names that are in the incoming links.
    For example: utm_source and utm_campaign.
  2. 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.
  3. 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.

 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 Twitter, work differently than Google Ads or a cross-platform like Facebook. 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:

  1. Make a list of the media source and campaign parameter names that are in the incoming links.
  2. Provide these in the list of parameters to the web developer.
    T
    he 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

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 parameter is 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://hotel.me/af_pid=click_ad_network_int&c=orlando&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.

Was this article helpful?