OneLink Smart Script V2—Web-to-app URL generator

At a glance: Customize OneLinks that are automatically generated and embedded behind a button or banner on your brand's website.

About OneLink Smart Script

OneLink Smart Script uses incoming URLs leading to the webpage to automatically generate unique outgoing OneLink URLs leading to the app store.

The outgoing URLs are generated using arguments you receive from the marketer and input into the script. Note: The afParameters argument has a structure made up of several other arguments (parameters), each of which contains a configuration object that has keys, override values, and a default value.

Implementation steps

To set up the Smart Script, you can either:

  • Embed the script in your website.
  • Use Google Tag Manager.

Embed the script in your website

To embed the script to your website:

  1. Download the script and import it into the mobile site/pages on which you want it to run.
  2. Get from the marketer: The arguments to call the script which maps the incoming parameters to the outgoing parameters.
  3. Initialize the Smart Script arguments and configuration objects.
  4. Generate the URLs by calling the script in the web/landing page HTML using the following method:
var result = window.AF_SMART_SCRIPT.generateOneLinkURL({
  oneLinkURL,
  afParameters,
  referrerSkipList, // optional
  urlSkipList // optional
})

Possible return values are:
- An outgoing Onelink URL.
- null. If the script returns null, implement your desired flow. For example: the web/landing page's existing URL is not changed.

Use Google Tag Manager

To set up the Smart Script in Google Tag Manager:

  1. Confirm that the marketer has the OneLink Smart Script code, followed by the Smart Script initialization code (with the arguments and configuration objects).
  2. Make sure the initialization code has a result passed to AF_SMART_SCRIPT_RESULT that is not null.
  3. Use the result value as needed. For example, to place it as a link under a CTA on your website.

Create a QR code with the Smart Script result

Prerequisite: Smart Script V2.1+

To create a QR code:

  1. Create a div tag with a specific ID in your site's HTML page to host the QR code.
    You can style the div tag however you want.
  2. After you run the Smart Script and generate a OneLink URL, call the following function and pass it the div ID:
window.AF_SMART_SCRIPT.displayQrCode("my_qr_code_div_id");
  1. Best practice: Once you have the result, show the QR code when users are on desktop and show the button with the link when users are on mobile.

Arguments

Argument Remarks Example
oneLinkURL (required)
  • Provide the OneLink template domain + template ID. Note: Not a OneLink custom link URL!
  • yourbrand.onelink.me/A1b2
  • Branded domain example: click.yourbrand.com/A1b2

afParameters

(required)

 

 

 


mediaSource

(required)

Configuration object for media source

  • Keys: ['incoming_mediasource’' 'utm_source']
  • Override values: {twitter: 'twitter_int', orig_src: 'new_src'}
  • Default value: ['any_source']

campaign

Configuration object for campaign

  • Keys: ['incoming_campaign', 'utm_campaign']
  • Override values: {campaign_name: 'new_campaign_name'}
  • Default value: ['any_campaign_name']

channel

Configuration object for channel

  • Keys: ['incoming_channel', 'utm_channel']
  • Override values: {video: 'new_video'}
  • Default value: ['any_video']

ad

Configuration object for ad

  • Keys: ['incoming_ad', 'utm_ad']
  • Override values: {ad_name: 'new_ad_name'}
  • Default value: ['any_ad_name']
adSet

Configuration object for adset

  • Keys: ['incoming_adset', 'utm_adset']
  • Override values: {'adset_name': 'new_adset_name'}
  • Default value: ['any_adset_name']
deepLinkValue

Configuration object for deep_link_value

  • Keys: ['product_id', 'page_name']
  • Override values: {twenty_percent_off: 'thirty_percent_off'}
  • Default value: 'ten_percent_off'
afSub1-5

Configuration object for af_sub[1-5]

 
googleClickIdKey

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 (custom) query parameters
  • List of any other parameters you want to be included in the outgoing OneLink URL for attribution or deep linking, along with their configuration objects.
  • The name of the custom parameter is listed by the developer as paramKey in the configuration object.
  • paramKey: 'deep_link_sub1'
  • Keys: ['page_id']
  • Override values: {page12: 'new_page12'}
  • Default value: 'page1'
 
referrerSkipList
List of the strings in the HTTP referrer for a particular click (for example Twitter or Facebook) that if found, cause the Smart Script to return null. This can be useful for SRNs like Twitter and Facebook, for which clicks are already reported.  
urlSkipList List of the strings in the URL for a particular click (for example af_r) that if found, cause the Smart Script to return null. This can be useful if you use an AppsFlyer attribution link with af_r to redirect users to your mobile website, and don't want data from the original click to be lost.  

Configuration object

The OneLink Smart Script uses arguments to generate an outgoing URL based on the parameters of the incoming URL and the arguments defined in the script. The afParameters argument has a structure made up of several other arguments (parameters) used for attribution and deep linking, each of which contains a configuration object that has keys, override values, and a default value, as described in the table that follows.

Argument Description Example
keys
  • List of strings
  • List of possible parameter/s in the incoming URL the script looks for, the value of which is placed as the value in the outgoing URL.
  • The script searches from left to right and stops at the first match.
  • Example: ['in_channel', 'utm_channel']
  • For the channel parameter in the script, the script searches the incoming link for in_channel and uses the value as the value for channel.

overrideValues

  • Dictionary {string: string}
  • For values you want changed in the outgoing link, list the values in the incoming URL, alongside what you want them to be replaced with.
  • The script replaces the param values of the incoming URL with the values you define. 

Example: {'video': 'video_new'}

For the channel parameter in the script, anytime the incoming value is video, the script changes it to video_new on the outgoing link.

defaultValue
  • String
  • State what you want your "fallback" value to be.
  • If a parameter is not found from your key list, the defaultValue value is used in the outgoing URL.
  • You can force a default value by passing an empty keys list.

Example: ['web_video']

For the channel parameter in the script, if you have the param in_channel is not found, web_video is used as the channel value.

Examples

Basic attribution

See example of the basic conversion of an incoming URL to an outgoing OneLink URL, with a single key for media_source and campaign

Multiple keys

See example of the conversion of an incoming URL to an outgoing OneLink URL, with multiple keys for media_source and campaign.

UTM parameters

See example of the conversion of an incoming URL to an outgoing OneLink URL, with UTM parameters for media_source and campaign.

Override values

See example of the conversion of an incoming URL to an outgoing OneLink URL, replacing the incoming media_source value.

Default values

See example of the conversion of an incoming URL to an outgoing OneLink URL, using the default value when an incoming media_source value isn't found.

Forced default values

See example of the conversion of an incoming URL to an outgoing OneLink URL, using the default value even when an incoming media_source value is found.

Google click ID passthrough to af_sub

See example of the conversion of an incoming URL to an outgoing OneLink URL that passes the Google click ID to af_sub4. Note: When a GCLID is found, the script looks for the incoming parameter keyword, and puts the keyword value in the outgoing URL as the value of af_keywords.

Facebook click ID passthrough to af_sub

See example of the conversion of an incoming URL to an outgoing OneLink URL that passes the Facebook click ID to af_sub2.

Set attribution and OneLink parameters

See example of the conversion of an incoming URL to an outgoing OneLink URL with AppsFlyer attribution and OneLink parameters.

Set additional custom parameters

See example of the conversion of an incoming URL to an outgoing OneLink URL with additional custom parameters (including the af_prt parameter for agencies).

Referrer skip list

See example of how you can disable the Smart Script for a particular click (for example, from Twitter or Facebook) by creating a skip list. If any of the strings in the skip list appear in the HTTP referrer of the click, the Smart Script returns null.

URL skip list

See example of how you can disable the Smart Script for a particular string in the URL (for example, af_r) by creating a skip list. If any of the strings in the skip list appear in the URL of the click, the Smart Script returns null.

Smart Script set up with Google Tag Manager

See example of the conversion of an incoming URL to an outgoing OneLink URL using OneLink Smart Script set up using Google Tag Manager.

QR code

See example of how the Smart Script generates a QR code.


Did this page help you?