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
Users arrive at your mobile website before reaching your app store page, either organically, or via advertising campaigns. However, since there are two clicks (the first that directs to the web page and the second that directs from the web page to the app store), collecting click conversion metrics and deep linking is problematic.
OneLink Smart Script solves these problems. The script:
- Uses the incoming URLs leading to the webpage to automatically generate unique outgoing OneLink URLs leading to the app store.
- Provides accurate web-to-app metrics collection for all media sources.
- Can be used for deep linking.
- Runs seamlessly on any webpage or landing page.
Procedures
To set up the Smart Script, the following action checklist of procedures need to be completed.
Procedure checklist |
---|
|
|
|
|
Import the script
To import the script to your website:
- Download the script.
- Import it into the mobile site/pages on which you want it to run.
Initialize the script
To initialize the script:
- Get from the marketer: The parameters/values that the outgoing OneLink URL should contain (based on what is contained in the incoming URL). See the table that follows for details.
- Initialize the Smart Script using the arguments (parameters).
Parameter | Type | Functionality | Example |
---|---|---|---|
oneLinkURL [required] | string |
| yourbrand.onelink.me/mylp |
pidKeysList | List of strings |
| ['af_pid', 'utm_source'] |
pidOverrideList | dictionary {string: string, | Lists the media source values in the incoming URL, alongside what you them to be replaced with. | { |
pidStaticValue | string | If a pid key is not found in the pidKeysList, the pidStaticValue is used as the pid value. |
|
campaignKeysList | List of strings | Lists the campaign parameter/s in the incoming URL that will be placed as the c parameter in the outgoing URL. | ['af_campaign', 'utm_campaign'] |
campaignStaticValue | string | If a campaign key is not found in the campaignKeysList, the campaignStaticValue is used as the c value. |
|
gclIdParam | string |
| 'af_sub5' |
Run setters
To run setters:
- Get from the marketer: Any other parameters and values that the outgoing OneLink URL should contain (based on what is contained in the incoming URL).
- Run the setters using the sequence that follows:
onelinkGenerator.set[parameter]("parameter value", "optional static value");
Generate URLs
To generate outgoing OneLink URLs:
- Run the method generateURL in the web/landing page HTML that calls the script.
Possible return values are:- An outgoing Onelink URL
- Null. If the script returns null, the web/landing page's existing URL is not be changed.
Examples
Basic attribution
Incoming URL:
https://liaz-af.github.io/af-onelink-smart-script/examples/basic_url.html?af_c=gogo&af_pid=email
Script:
const onelinkGenerator = new window.AF.OneLinkUrlGenerator(
{oneLinkURL: "https://engmntqa.onelink.me/LtRd/",
pidKeysList: ['af_pid'],
campaignKeysList: ['af_c']
});
const url = onelinkGenerator.generateUrl();
Outgoing URL:
https://engmntqa.onelink.me/LtRd/?pid=email&c=gogo&af_js_web=true
UTM parameters
Incoming URL:
https://liaz-af.github.io/af-onelink-smart-script/examples/utm_params.html?utm_source=email&utm_campaign=summer_sale
Script:
onst onelinkGenerator = new window.AF.OneLinkUrlGenerator(
{oneLinkURL: "https://engmntqa.onelink.me/LtRd/",
pidKeysList: ['af_pid', 'utm_source'],
campaignKeysList: ['af_c', 'utm_campaign']
});
const url = onelinkGenerator.generateUrl();
Outgoing URL:
https://engmntqa.onelink.me/LtRd/?pid=email&c=summer_sale&af_js_web=true
PID and campaign static values
Incoming URL:
https://liaz-af.github.io/af-onelink-smart-script/examples/static_val.html?af_not_c=gogo&af_not_pid=email
Script:
const onelinkGenerator = new window.AF.OneLinkUrlGenerator(
{oneLinkURL: "https://engmntqa.onelink.me/LtRd/",
pidKeysList: ['af_pid'],
pidStaticValue: 'my_static_pid',
campaignKeysList: ['af_c'],
campaignStaticValue: 'my_static_cmpn',
});
const url = onelinkGenerator.generateUrl();
Outgoing URL:
https://engmntqa.onelink.me/LtRd/?pid=my_static_pid&c=my_static_cmpn&af_js_web=true
Override PIDs
Incoming URL:
https://liaz-af.github.io/af-onelink-smart-script/examples/override_pid.html?af_pid=twitter&af_c=big_social
Script:
const onelinkGenerator = new window.AF.OneLinkUrlGenerator(
{oneLinkURL: "https://engmntqa.onelink.me/LtRd/",
pidKeysList: ['af_pid'],
campaignKeysList: ['af_c'],
pidOverrideList: { twitter: 'twitter_out',
snapchat: 'snapchat_out'
}
});
const url = onelinkGenerator.generateUrl();
Outgoing URL:
https://engmntqa.onelink.me/LtRd/?pid=twitter_out&c=big_social&af_js_web=true
Google Click ID passthrough to af_sub
Incoming URL:
https://liaz-af.github.io/af-onelink-smart-script/examples/gclid.html?af_pid=sms&af_c=candles&gclid=1a2b3c
Script:
const onelinkGenerator = new window.AF.OneLinkUrlGenerator(
{oneLinkURL: "https://engmntqa.onelink.me/LtRd/",
pidKeysList: ['af_pid'],
campaignKeysList: ['af_c'],
gclIdParam: 'af_sub4'
});
const url = onelinkGenerator.generateUrl();
Outgoing URL:
https://engmntqa.onelink.me/LtRd/?pid=google_lp&c=candles&af_js_web=true&af_sub4=1a2b3c
Set OneLink parameters
To create a long link top be used for deep linking, you can pass both custom parameters and predefined parameters. See the functions for passing parameters in the sample script that follows.
To pass a custom parameter:
- Call the function
setCustomParameter
.
ThesetCustomParameter
accepts three arguments:
1. [Mandatory] The key in the incoming URL from which the script takes the value to set in the outgoing URL.
2. [Mandatory] The key to be specified in the outgoing URL.
3. [Optional] A static fallback value, in case the key in the first argument isn’t found in the URL.
If the key in the first argument isn’t found, and no static fallback is defined, the parameter is skipped.
To pass a predefined parameter
- Call the function(s) in the sample script that follows (except
setCustomParameter
).
Each function accepts two arguments:
1. [Mandatory] The key in the incoming URL from which the script takes the value to set in the outgoing URL.
2. [Optional] A static fallback value, in case the key in the first argument isn’t found in the URL.
If the key in the first argument isn’t found, and no static fallback is defined, the parameter is skipped.
Incoming URL:
https://liaz-af.github.io/af-onelink-smart-script/examples/setters.html?af_c=gogo&af_pid=email
Script:
const onelinkGenerator = new window.AF.OneLinkUrlGenerator(
{oneLinkURL: "https://engmntqa.onelink.me/LtRd/",
pidKeysList: ['af_pid'],
campaignKeysList: ['af_c']
});
onelinkGenerator.setDeepLinkValue("original_url_deeplinkvalue", "yessss");
onelinkGenerator.setChannel("original_url_channel", "new_channel");
onelinkGenerator.setAdset("no_adset", "adset");
onelinkGenerator.setAd("original_url_ad", "new_ad");
onelinkGenerator.setAfSub1("original_url_sub1", "ram_afsub1");
onelinkGenerator.setAfSub2("original_url_sub2");
onelinkGenerator.setAfSub3("no_sub3", "new_afsub3");
onelinkGenerator.setAfSub4("original_url_sub4");
onelinkGenerator.setAfSub5("neverfind_sub5", "new_afsub5");
onelinkGenerator.setCustomParameter("original_url_fruit_name", "onelink_my_custom_param", "apples");
const url = onelinkGenerator.generateUrl();
Updated 2 days ago