Smart script for cross-platform

Smart Script can generate OneLinks that redirect users to non-mobile stores where they can download, install, or purchase PC, CTV or console apps.

Implementation steps

Create a direct click URL

To create a direct click URL, follow these steps:

  1. Download the Smart Script.

  2. Get the arguments to call the script, mapping the incoming parameters to the marketer’s parameters.

  3. Initialize the Smart Script arguments and configuration objects as in the following example:

    var mediaSource = { keys: ["my_media_source"], defaultValue: "my_default_media_source" };
    
    var campaign    = { keys: ["my_campaign"],     defaultValue: "my_default_campaign" };
    
  4. Generate the URLs by calling the script in your web or landing page HTML, using the following method:

     var result = window.AF_SMART_SCRIPT.generateDirectClickURL({
       afParameters: afParameters,
       platform: platform.platformName,
       app_id: platform.appid,
       redirectURL: platform.redirectURL,
     })
    
  5. Check the return value in result. Possible return values are:

    • An outgoing Direct URL (https://engagements.appsflyer.com). For additional Direct URL examples, see the demo page below. Use the result value as needed, for example, to place it as a link under a call to action (CTA) on your website.
    • A null value. If the script returns null, implement your error-handling flow. For example, when the existing URL of the web or landing page is not changed.

    For example:

     //In  itializing Smart Script arguments
     // If a media source key is NOT FOUND on the link and NO default value is found, the script will return a null string 
     var mediaSource = {keys: ["my_media_source"], defaultValue: "my_default_media_source"};
     var campaign = {keys: ["my_campaign"], defaultValue: "my_default_campaign"};
    
     //Calling the function after embedding the code will be through a global parameter on the window object called window.AF_SMART_SCRIPT
     //Onelink URL is generated
    
     var result = window.AF_SMART_SCRIPT.generateDirectClickURL({
       afParameters:{
         mediaSource: mediaSource,
         campaign: campaign
       },
       platform: 'steam',
       app_id: '123456',
       redirectURL:'https://store.steampowered.com/app/123456/Team_Fortress_2/'
     })
    
     var result_url = "No output from script"
     if (result) {
       result_url = result.clickURL;            
     }
    

    See example of the conversion of an incoming URL to an outgoing direct click URL for a Steam game.

📘

Note

In order to ensure incoming URL parameters will be mapped to the generated outgoing URL, it is recommended to import the Smart Script in every website page, whether an outgoing URL is generated in the page or not.

For more information and a full example, see here.

Create a QR code with the Smart Script result

To create a QR code with the Smart Script result, see here.

Fire an impression

To fire an impression, see here

Arguments

Argument Remarks Example

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']
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'
platform A string describes the platform. MUST be from this list:
  • smartcast
  • tizen
  • roku
  • webos
  • vidaa
  • playstation
  • android
  • ios
  • steam
  • quest
  • battlenet
  • nativepc
  • epic
  • switch
"steam"
app_id Application ID "123456"
redirectURL The URL the user will be redirected "https://store.steampowered.com/app/123456/Team_Fortress_2/"

Game landing page demo

You can find here a fully functional demo landing page which demonstrates integrating the generateDirectClickURL Smart Script code.