[Legacy] OneLink Smart Script V1

At a glance: Customize OneLinks that are automatically generated and embedded behind a button or banner on your brand's website. Note: Although not mandatory, consider migrating to OneLink Smart Script V2.

1920

关于OneLink智能脚本

用户在到达您的应用商店页面之前就已经到达了您的移动网站,无论是以自然地方式,还是通过广告活动。但是,由于有两次点击(第一次直接指向网页,第二次从网页指向应用商店),收集点击转化指标和深度链接是有问题的。 

OneLink智能脚本解决了这些问题。脚本:

  • 使用通往网页传入的URL,自动生成通往应用商店唯一传出的OneLink URL。 
  • 为所有媒体渠道提供准确的web-to-app指标收集。 
  • 可用于深度链接。
  • 在任何网页或登陆页面上无缝运行。

程序

要设置智能脚本,需要完成以下操作步骤核对表。

程序核对表
1. Import the script to your website.
2. Initialize the Smart Script object OneLinkUrlGenerator with the parameters and values.
3. [Optional] Run setters with additional parameters and values.
4. Generate the URLs.

Import the script

将脚本导入到您的网站

  1. 下载脚本
  2. 将其导入到您希望运行的移动网站/页面中。

Initialize the script

初始化脚本

  1. 从营销人员处获取:传出的OneLink URL应包含的参数/值(基于传入URL中包含的内容)。有关详细信息,请参阅下表。
  2. Initialize the Smart Script object OneLinkUrlGenerator using the arguments (parameters).
参数类型功能举例
oneLinkURL [必填]字符串- Serves as the base for all links generated by the script.
- It is the OneLink template domain + template ID.
yourbrand.onelink.me/A1b2
Branded domain example: click.yourbrand.com/A1b2
pidKeysList字符串列表- Lists the media source parameter/s in the incoming URL that will be placed as the pid parameter in the outgoing URL.
- If there are multiple media source params in the incoming link (for example af_pid and utm_source), the pidKeysList scans the params from first to last, and uses the first match found.
['af_pid', 'utm_source']
pidOverrideListdictionary {string: string,
…}
Lists the media source values in the incoming URL, alongside what you want them to be replaced with.{
'twitter': 'twitter_int',
'snapchat': 'snapchat_int',
'some_social_net': 'some_social_net_int'
}
pidStaticValue字符串如果在pidKeysList中找不到pid密钥,则使用pidStaticValue作为pid值。- 'website'
- 'landing_page'
campaignKeysList字符串列表列出传入URL中的广告活动参数,这些参数将作为c参数放置在传出的URL中。['af_campaign', 'utm_campaign']
campaignStaticValue字符串如果在campaignKeysList中找不到广告活动密钥,则使用campaignStaticValue作为c值。- 'website'
- 'landing_page'
gclIdParam字符串- Defines which parameter in the outgoing URL carries the GCLID.
- Any parameter can be chosen. Note! To display in AppsFlyer raw data reports, the param must be one of af_sub[1-5].
'af_sub5'
skipList字符串If any strings in the skip list appear in the HTTP referrer, the Smart Script returns null.- '[‘facebook’, ‘twitter’]'
- Facebook is in the skipList by default.

Run setters

运行设置器

  1. 从营销人员处获取:传出的OneLink URL应包含的任何其他参数和值(基于传入URL中包含的内容)。
  2. 使用下面的模板运行设置器:
onelinkGenerator.set[parameter]("parameter value", "optional static value");

例如:

onelinkGenerator.setAfSub1("original_url_sub1", "ram_afsub1");

Generate URLs

生成传出的OneLink URL

  • 在调用脚本的网页/登陆页面HTML中运行方法generateURL。
    可能的返回值包括:
    • 传出的Onelink URL
    • Null。如果脚本返回null,则不会更改网站/登陆页面的现有URL。

示例

Basic attribution

Incoming URL:
https://appsflyersdk.github.io/appsflyer-onelink-smart-script/v1/examples/basic_url.html?af_c=gogo&af_pid=email

脚本

const onelinkGenerator =  new window.AF.OneLinkUrlGenerator(
        {oneLinkURL: "https://engmntqa.onelink.me/LtRd/",
         pidKeysList: ['incoming_media_source'],
         campaignKeysList: ['incoming_campaign']
      });
      const url = onelinkGenerator.generateUrl();

传出的URL
https://engmntqa.onelink.me/LtRd/?pid=email&c=gogo&af_js_web=true

UTM parameters

Incoming URL:
https://appsflyersdk.github.io/appsflyer-onelink-smart-script/v1/examples/utm_params.html?utm_source=email&utm_campaign=summer_sale

脚本

onst onelinkGenerator =  new window.AF.OneLinkUrlGenerator(
        {oneLinkURL: "https://engmntqa.onelink.me/LtRd/",
         pidKeysList: ['incoming_media_source', 'utm_source'],
         campaignKeysList: ['incoming_campaign', 'utm_campaign']
      });
      const url = onelinkGenerator.generateUrl();

传出的URL
https://engmntqa.onelink.me/LtRd/?pid=email&c=summer_sale&af_js_web=true

PID and campaign static values

Incoming URL:
https://appsflyersdk.github.io/appsflyer-onelink-smart-script/v1/examples/static_val.html?af_not_c=gogo&af_not_pid=email

脚本

const onelinkGenerator =  new window.AF.OneLinkUrlGenerator(
        {oneLinkURL: "https://engmntqa.onelink.me/LtRd/",
         pidKeysList: ['incoming_media_source'],
         pidStaticValue: 'my_static_pid',
         campaignKeysList: ['incoming_campaign'],
         campaignStaticValue: 'my_static_cmpn',
      });
      const url = onelinkGenerator.generateUrl();

传出的URL
https://engmntqa.onelink.me/LtRd/?pid=my_static_pid&c=my_static_cmpn&af_js_web=true

Override PIDs

Incoming URL:
https://appsflyersdk.github.io/appsflyer-onelink-smart-script/v1/examples/override_pid.html?af_pid=twitter&af_c=big_social

脚本

const onelinkGenerator =  new window.AF.OneLinkUrlGenerator(
        {oneLinkURL: "https://engmntqa.onelink.me/LtRd/",
         pidKeysList: ['incoming_media_source'],
         campaignKeysList: ['incoming_campaign'],
         pidOverrideList: { twitter: 'twitter_out',
                            snapchat: 'snapchat_out'
                          }
      });
      const url = onelinkGenerator.generateUrl();

传出的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://appsflyersdk.github.io/appsflyer-onelink-smart-script/v1/examples/gclid.html?af_pid=sms&af_c=candles&gclid=1a2b3c

脚本

const onelinkGenerator =  new window.AF.OneLinkUrlGenerator(
        {oneLinkURL: "https://engmntqa.onelink.me/LtRd/",
         pidKeysList: ['incoming_media_source'],
         campaignKeysList: ['incoming_campaign'],
         gclIdParam: 'af_sub4'
      });
      const url = onelinkGenerator.generateUrl();

传出的URL
https://engmntqa.onelink.me/LtRd/?pid=google_lp&c=candles&af_js_web=true&af_sub4=1a2b3c

Set OneLink parameters

要创建用于深度链接的长链接,可以传递自定义参数和预定义参数。请参阅以下示例脚本中用于传递参数的函数。

传递自定义参数:

  • Call the function setCustomParameter.
    The setCustomParameter 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.

如果没有找到第一个参数中的密钥,并且没有定义静态回退,则跳过该参数。

传递预定义参数

  • 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.

如果没有找到第一个参数中的密钥,并且没有定义静态回退,则跳过该参数。

Incoming URL:
https://appsflyersdk.github.io/appsflyer-onelink-smart-script/v1/examples/setters.html?af_c=gogo&af_pid=email

脚本

const onelinkGenerator =  new window.AF.OneLinkUrlGenerator(
        {oneLinkURL: "https://engmntqa.onelink.me/LtRd/",
         pidKeysList: ['incoming_media_source'],
         campaignKeysList: ['incoming_campaign']
      });
      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();

传出的URL
https://engmntqa.onelink.me/LtRd/?pid=email&c=gogo&af_js_web=true&deep_link_value=yessss&af_channel=new_channel&af_adset=adset&af_ad=new_ad&af_sub1=ram_afsub1&af_sub3=new_afsub3&af_sub5=new_afsub5&onelink_my_custom_param=apples

Set additional attribution parameters

您可以使用其他归因参数创建长链接。请参阅以下示例脚本中用于传递参数的函数。

添加归因参数:

  • Call the function setCustomParameter.
    The setCustomParameter accepts three arguments:
    1. [Mandatory] The key of the attribution parameter in the incoming URL from which the script takes the value to set in the outgoing URL.
    2. [Mandatory] The key of the attribution parameter 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.

如果没有找到第一个参数中的密钥,并且没有定义静态回退,则跳过该参数。

Incoming URL:
https://appsflyersdk.github.io/appsflyer-onelink-smart-script/v1/examples/set_af_params.html?af_c=gogo&af_pid=email&partner_name=bigagency

脚本

onelinkGenerator.setCustomParameter("incoming_site_id", "af_siteid", "defaultSiteID");

Outgoing URL:
https://engmntqa.onelink.me/LtRd/?pid=email&c=gogo&af_js_web=true&af_siteid=defaultSiteID

Skip clicks from Twitter or Facebook

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.

脚本

const onelinkGenerator =  new window.AF.OneLinkUrlGenerator(
      {oneLinkURL: "https://engmntqa.onelink.me/LtRd/",
        pidKeysList: ['original_pid'],
        campaignKeysList: ['original_campaign'],
        skipList: ['twitter', 'facebook']
    });
const url = onelinkGenerator.generateUrl();

Don't skip any clicks

You can ensure that OneLink Smart Script works for all clicks, and never skips any, by passing an empty skip list.

脚本

const onelinkGenerator =  new window.AF.OneLinkUrlGenerator(
      {oneLinkURL: "https://engmntqa.onelink.me/LtRd/",
        pidKeysList: ['original_pid'],
        campaignKeysList: ['original_campaign'],
        skipList: []
    });
const url = onelinkGenerator.generateUrl();