---
updatedAt: 2026-09-22T09:44:43.000Z
---

# OneLink Smart Script V2

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

<Recipe slug="smart-script-quick-start-single-key" title="Smart Script Quick Start - Single Key" />

<Embed title="" typeOfEmbed="iframe" url="https://appsflyer.wistia.com/medias/9sx58ic0e3" href="https://appsflyer.wistia.com/medias/9sx58ic0e3" html="%3Ciframe%20class%3D%22embedly-embed%22%20src%3D%22%2F%2Fcdn.embedly.com%2Fwidgets%2Fmedia.html%3Fsrc%3Dhttps%3A%2F%2Ffast.wistia.net%2Fembed%2Fiframe%2F9sx58ic0e3%26display_name%3DWistia%2C%2BInc.%26url%3Dhttps%3A%2F%2Fappsflyer.wistia.com%2Fmedias%2F9sx58ic0e3%26image%3Dhttps%3A%2F%2Fembed-ssl.wistia.com%2Fdeliveries%2F36d0dbecf1b69f6898d748446b91153fb897c467.jpg%3Fimage_crop_resized%3D640x360%26key%3Df2aa6fc3595946d0afc3d76cbbd25dc3%26type%3Dtext%2Fhtml%26schema%3Dwistia%22%20width%3D%22640%22%20height%3D%22360%22%20scrolling%3D%22no%22%20title%3D%22Wistia%2C%20Inc.%20embed%22%20frameborder%3D%220%22%20allow%3D%22autoplay%3B%20fullscreen%22%20allowfullscreen%3D%22true%22%3E%3C%2Fiframe%3E" />

## About OneLink Smart Script

OneLink Smart Script uses incoming URLs leading to the webpage to automatically generate unique outgoing OneLink URLs. For mobile apps, Smart Script generates OneLink URLs that lead to the app store. Smart Script also supports PC, console, CTV, and Steam apps, see[ Smart Script for PC, console, and Steam ](https://dev.appsflyer.com/hc/docs/create-direct-click-url)for that flow.

The outgoing URLs are generated using [arguments](https://dev.appsflyer.com/hc/docs/onelink-smart-script-v2web-to-app-url-generator#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](https://dev.appsflyer.com/hc/docs/onelink-smart-script-v2web-to-app-url-generator#configuration-object) that has keys, override values, and a default value.

<Callout icon="📘" theme="info">
  ### Building for PC, console, or Steam?

  This article covers the mobile flow, which calls `generateOneLinkURL`. If you're implementing Smart Script for a PC, console, CTV, or Steam app, go to [Smart Script for PC, console, and Steam](https://dev.appsflyer.com/hc/docs/create-direct-click-url), which covers `generateDirectClickURL` instead.
</Callout>

## Implementation steps

To set up the Smart Script, you can either:

### Embed the script in your website

The Smart Script initialization and calling code can be either come from the Smart Script generator in the AppsFlyer dashboard (**recommended**), or imported and called manually by the developer.

<Callout icon="📘" theme="info">
  ### Preserve incoming URL parameters

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

  Available from version 2.5.0.

  More details and a full example [here](https://dev.appsflyer.com/hc/docs/dl_smart_script_v2#preserve-incoming-url-parameters-across-pages).
</Callout>

#### Use code generated by the Smart Script generator

1. Get the file from the marketer that includes the script, initialization code, and arguments.
2. Test the script on the [Smart Script test page](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/test_page.html). Ensure the correct outgoing URL is generated.
3. Follow the [test and use Smart Script result instructions](https://dev.appsflyer.com/hc/docs/onelink-smart-script-v2web-to-app-url-generator#check-and-use-smart-script-result).

[See integration example in Github](https://github.com/AppsFlyerSDK/appsflyer-onelink-smart-script/blob/main/examples/generator_integration.html)

#### Manually configure the script

1. Download [the script](https://onelinksmartscript.appsflyer.com/onelink-smart-script-latest.js) or it's [minified version](https://onelinksmartscript.appsflyer.com/onelink-smart-script-latest-minified.js).
2. Get the arguments to call the script which map the incoming parameters to the outgoing parameters from the marketer.
3. Initialize the Smart Script [arguments](https://dev.appsflyer.com/hc/docs/onelink-smart-script-v2web-to-app-url-generator#arguments) and [configuration objects](https://dev.appsflyer.com/hc/docs/onelink-smart-script-v2web-to-app-url-generator#configuration-object).
4. Generate the URLs by calling the script in the web/landing page HTML using the following method:

```javascript
var result = window.AF_SMART_SCRIPT.generateOneLinkURL({
  oneLinkURL,
  afParameters,
  referrerSkipList, // optional
  urlSkipList // optional
})
```

5. Follow the [test and use Smart Script result instructions](https://dev.appsflyer.com/hc/docs/onelink-smart-script-v2web-to-app-url-generator#check-and-use-smart-script-result).

#### Check and use Smart Script result

1. Check the return value in `result`. Possible return values are:
   * An outgoing Onelink URL. Use the result value as needed. For example, to place it as a link under a CTA on your website.
   * `null`. If the script returns `null`, implement your desired error flow. For example: the web/landing page's existing URL is not changed.

```javascript
      var result_url = "No output from script"
      if (result) {
            result_url = result.clickURL;            
            // Put the generated OneLink URL behind CTA buttons
            document.getElementById('andrd_link').setAttribute('href', result_url);
            document.getElementById('ios_link').setAttribute('href', result_url);
            // Optionally - Create QR code from the generated OneLink URL
            window.AF_SMART_SCRIPT.displayQrCode("my_qr_code_div_id");
            //The size of the QR code is defined in the CSS file under #my_qr_code_div_id
            // #my_qr_code_div_id canvas { 
            //  height: 200px;
            //  width: 200px;
            //}
            // Optionally - fire an impression.
            // The impression will fire to https://impressions.onelink.me//.... 
            setTimeout(() => {
              window.AF_SMART_SCRIPT.fireImpressionsLink();
              console.log("Impression fired"); 
            }, 1000);
      }
```

### Use Google Tag Manager

To set up the Smart Script in Google Tag Manager:

1. Confirm that the marketer followed their [instructions](https://support.appsflyer.com/hc/en-us/articles/4413588932241#set-up-onelink-smart-script) and placed the Smart Script code into GTM.
2. Check the return value in `AF_SMART_SCRIPT_RESULT`. Possible return values are:
   * An outgoing OneLink URL. Use the result value as needed. For example, to place it as a link under a CTA on your website.
   * `null`. If the script returns `null`, implement your desired error flow. For example: the web/landing page's existing URL is not changed.

```javascript
      var result_url = AF_SMART_SCRIPT_RESULT.clickURL;
      if (result_url) {
            document.getElementById('andrd_link').setAttribute('href', result_url);
            document.getElementById('ios_link').setAttribute('href', result_url);
            // Optionally - Create QR code from the generated OneLink URL
            window.AF_SMART_SCRIPT.displayQrCode("my_qr_code_div_id");
            //The size of the QR code is defined in the CSS file under #my_qr_code_div_id
            // #my_qr_code_div_id canvas { 
            //  height: 200px;
            //  width: 200px;
            //}
            // Optionally - fire an impression.
            // The impression will fire to https://impressions.onelink.me//.... 
            setTimeout(() => {
              window.AF_SMART_SCRIPT.fireImpressionsLink();
              console.log("Impression fired"); 
            }, 1000);            
      }
```

3. Test the script on the [Smart Script test page](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/test_page.html). Ensure the correct outgoing URL is generated.

### Create a QR code with the Smart Script result

**Prerequisite**: Smart Script V2.6+

<Callout icon="📘" theme="info">
  ### Best practices

  - Customize the QR code according to your app brand with a center logo and a relevant code color
  - Show the QR code when users are on desktop and show the button with the link when users are on mobile
</Callout>

**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.<br />You can style the div tag however you want.
2. After you run the Smart Script and generate a OneLink URL, call the following method `displayQrCode`

#### `displayQrCode`

***

**Method signature**

```javascript
const qrOptions = {
  logo,
  colorCode
}

window.AF_SMART_SCRIPT.displayQrCode(divId, qrOptions)
```

**Input arguments**

| Type     | Mandatory | Name        | Description                                                                 | Comment                                                                               |
| :------- | :-------- | :---------- | :-------------------------------------------------------------------------- | :------------------------------------------------------------------------------------ |
| `String` | Yes       | `divID`     | A `div` tag with a specific ID in your site's HTML page to host the QR code |                                                                                       |
| `Object` | No        | `qrOptions` | Configuration object (see details in the table below)                       | If the object is missing, the QR code will be created without a logo in default color |

`qrOptions`**&#x20;object**

| Type     | Mandatory | Name        | Description                            | Comment                                                                          |
| :------- | :-------- | :---------- | :------------------------------------- | :------------------------------------------------------------------------------- |
| `String` | No        | `logo`      | A valid image URL or an image data-URI | If the value is invalid, the QR code will be generated without the logo          |
| `String` | No        | `colorCode` | Hex color of the QR code               | If the value is invalid, the code color will fallback to the default black color |

**Usage examples:**

* *QR code without logo and without custom color* [Github example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/qr_code.html?incmp=gogo\&inmedia=email)
* *QR code with logo and custom code color* [Github example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/qr_code_logo_color.html?incmp=gogo\&inmedia=email)

### Fire an impression

You can fire an impression when a page loads, a CTA or banner displays, etc. **Note**: Whether you can fire impressions from desktop or console depends on your OneLink template. Templates with mobile-only support can only fire impressions on mobile devices. Templates with cross-platform support can also fire impressions from desktop or console.

**Prerequisite**: Smart Script V2.2+

**To fire an impression**:

1. Follow the instructions to run the Smart Script and generate a click URL.
2. Make sure the result is valid (and not null).
3. Run the following impression function:

<Callout icon="🚧" theme="warn">
  ### A must-do workaround

  Please wrap the call to `fireImpressionsLink` with `setTimeout` to make sure there is at least 1 second of delay between the call to `generateOneLinkURL` and `fireImpressionsLink`
</Callout>

```javascript
setTimeout(() => {
  window.AF_SMART_SCRIPT.fireImpressionsLink();
  console.log("Impression fired"); 
}, 1000);
```

You can find examples for firing impressions for [mobile only](#impressions---onelink-template-with-mobile-only-support) and for [cross platform support](#impressions---onelink-template-with-cross-platform-support)

## Arguments

<HTMLBlock>{`
<table class="table--hover table--striped table--color-header unsortable" style="height: 532px; width: 842px;">
  <thead>
    <tr style="height: 40px;">
      <th style="width: 272.312px;" colspan="2">Argument</th>
      <th style="width: 291.5px; height: 40px;">Remarks</th>
      <th style="width: 268.188px; height: 40px;">Example</th>
    </tr>
  </thead>
  <tbody>
    <tr style="height: 19px;">
      <td style="width: 264.312px;" colspan="2">oneLinkURL (required)</td>
      <td style="width: 283.5px; height: 19px;">
        <ul>
          <li>
            Provide the OneLink template domain + template ID.
            <strong>Note: </strong>Not a OneLink custom link URL!
          </li>
        </ul>
      </td>
      <td style="width: 260.188px; height: 19px;">
        <ul>
          <li>
            <strong>yourbrand.onelink.me/A1b2</strong>
          </li>
          <li>
            Branded domain example: <strong>click.yourbrand.com/A1b2</strong>
          </li>
        </ul>
      </td>
    </tr>
    <tr style="height: 19px;">
      <td style="width: 119.953px;" rowspan="9">
        <p>afParameters</p>
        <p>(required)</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <span style="font-weight: 400;"><br></span>
      </td>
      <td style="width: 133.359px; height: 19px;">
        <p>mediaSource</p>
        <p>(required)</p>
      </td>
      <td style="width: 283.5px; height: 19px;">
        <p>Configuration object for media source</p>
      </td>
      <td style="width: 260.188px; height: 19px;">
        <ul>
          <li>Keys: ['incoming_mediasource’' 'utm_source']</li>
          <li>
            Override values: {twitter: 'twitter_int', orig_src: 'new_src'}
          </li>
          <li>Default value: ['any_source']</li>
        </ul>
      </td>
    </tr>
    <tr style="height: 40px;">
      <td style="width: 133.359px; height: 40px;">
        <p>campaign</p>
      </td>
      <td style="width: 283.5px; height: 40px;">
        <p>Configuration object for campaign</p>
      </td>
      <td style="width: 260.188px; height: 40px;">
        <ul>
          <li>Keys: ['incoming_campaign', 'utm_campaign']</li>
          <li>Override values: {campaign_name: 'new_campaign_name'}</li>
          <li>Default value: ['any_campaign_name']</li>
        </ul>
      </td>
    </tr>
    <tr>
      <td style="width: 133.359px;">
        <p>channel</p>
      </td>
      <td style="width: 283.5px;">
        <p>Configuration object for channel</p>
      </td>
      <td style="width: 260.188px;">
        <ul>
          <li>Keys: ['incoming_channel', 'utm_channel']</li>
          <li>Override values: {video: 'new_video'}</li>
          <li>Default value: ['any_video']</li>
        </ul>
      </td>
    </tr>
    <tr style="height: 83px;">
      <td style="width: 133.359px; height: 83px;">
        <p>ad</p>
      </td>
      <td style="width: 283.5px; height: 83px;">
        <p>Configuration object for ad</p>
      </td>
      <td style="width: 260.188px; height: 83px;">
        <ul>
          <li>Keys: ['incoming_ad', 'utm_ad']</li>
          <li>Override values: {ad_name: 'new_ad_name'}</li>
          <li>Default value: ['any_ad_name']</li>
        </ul>
      </td>
    </tr>
    <tr style="height: 62px;">
      <td style="width: 133.359px; height: 62px;">adSet</td>
      <td style="width: 283.5px; height: 62px;">
        <p>Configuration object for adset</p>
      </td>
      <td style="width: 260.188px; height: 62px;">
        <ul>
          <li>Keys: ['incoming_adset', 'utm_adset']</li>
          <li>Override values: {'adset_name': 'new_adset_name'}</li>
          <li>Default value: ['any_adset_name']</li>
        </ul>
      </td>
    </tr>
    <tr style="height: 83px;">
      <td style="width: 133.359px; height: 83px;">deepLinkValue</td>
      <td style="width: 283.5px; height: 83px;">
        <p>
          Configuration object for <code>deep_link_value</code>
        </p>
      </td>
      <td style="width: 260.188px; height: 83px;">
        <ul>
          <li>Keys: ['product_id', 'page_name']</li>
          <li>Override values: {twenty_percent_off: 'thirty_percent_off'}</li>
          <li>Default value: 'new_offers_page'</li>
        </ul>
      </td>
    </tr>
    <tr>
      <td style="width: 133.359px;">afSub1-5</td>
      <td style="width: 283.5px;">
        <p>
          Configuration object for <code>af_sub[1-5]</code>
        </p>
      </td>
      <td>&nbsp;</td>
    </tr>
    <tr style="height: 40px;">
      <td style="width: 133.359px; height: 39px;">googleClickIdKey</td>
      <td style="width: 283.5px; height: 39px;">
        <p>
         Smart Script automatically maps the incoming <a href="https://support.google.com/google-ads/answer/9744275?hl=en" target="_blank" rel="noopener">GCLID</a> parameter value to the outgoing GCLID parameter: <code>gclid={gclid}</code>.<br>
          <strong>Note</strong>!
          <span style="font-weight: 400;">To display in AppsFlyer raw data reports, the param must be one of <strong>af_sub[1-5]</strong>.</span>
        </p>
      </td>
      <td style="width: 260.188px; height: 39px;">&nbsp;</td>
    </tr>
    <tr style="height: 83px;">
      <td style="width: 133.359px; height: 83px;">
        <span style="font-weight: 400;">Other (custom) query parameters</span><span style="font-weight: 400;"><br></span>
      </td>
      <td style="width: 283.5px; height: 83px;">
        <ul>
          <li>
            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.
          </li>
          <li>
            The name of the custom parameter is listed by the developer
            as <code>paramKey</code> in the configuration object.
          </li>
        </ul>
      </td>
      <td style="width: 260.188px; height: 83px;">
        <ul>
          <li>paramKey: 'deep_link_sub1'</li>
          <li>Keys: ['page_id']</li>
          <li>Override values: {page12: 'new_page12'}</li>
          <li>Default value: 'page1'</li>
        </ul>
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <span style="font-weight: 400;">&nbsp;</span><br>
        <span style="font-weight: 400;">referrerSkipList</span>
      </td>
      <td style="width: 283.5px;">
        List of the strings in the HTTP referrer for a particular click (for
        example Twitter or Meta ads) that if found, cause the Smart Script
        to return <code>null</code>. This can be useful for SRNs like Twitter
        and Meta ads, for which clicks are already reported.
      </td>
      <td style="width: 260.188px;">&nbsp;</td>
    </tr>
    <tr>
      <td style="width: 119.953px;" colspan="2">
        <span style="font-weight: 400;">urlSkipList</span>
      </td>
      <td style="width: 283.5px;">
        <span>List of the strings in the URL for a particular click (for example <code>af_r</code>) that if found, cause the Smart Script to return&nbsp;</span><code><span>null</span></code><span>. 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.</span>
      </td>
      <td style="width: 260.188px;">&nbsp;</td>
    </tr>
    <tr>
      <td style="width: 119.953px;" colspan="2">
        <span style="font-weight: 400;">webReferrer</span>
      </td>
      <td style="width: 283.5px;">
        <span>This argument defines a key in the outgoing URL, which its value will be a copy of the HTTP <code>document.referrer</code>. The referrer is saved in the first page the user lands in, and may be used in any consecutive page in this domain which runs Smart Script with this argument.</span>
      </td>
      <td style="width: 260.188px;">&nbsp;</td>
    </tr>
    <tr>
      <td style="width: 119.953px;" colspan="2">
        <span style="font-weight: 400;">SEO (optional)</span>
      </td>
      <td style="width: 283.5px;">
        <span>When enabled, and the media source isn't resolved from the URL parameter, Smart Script checks whether the user arrived from a search engine based on the web referrer URL, and sets the media source accordingly. (Available from version 2.10.3)</span>
      </td>
      <td style="width: 260.188px;">
        <ul>
          <li>SEO: true</li>
        </ul>
      </td>
    </tr>
  </tbody>
</table>
`}</HTMLBlock>

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

<HTMLBlock>{`
 <table class="table--hover table--striped table--color-header unsortable" style="height: 301px;">
        <thead>
          <tr style="height: 40px;">
            <th style="width: 147.969px; height: 40px;">Argument</th>
            <th style="width: 283.359px; height: 40px;">Description</th>
            <th style="width: 200.172px; height: 40px;">Example</th>
          </tr>
        </thead>
        <tbody>
          <tr style="height: 223px;">
            <td style="width: 139.969px; height: 223px;">keys</td>
            <td style="width: 275.359px; height: 223px;">
              <ul>
                <li>List of strings</li>
                <li>
                  <span>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.</span>
                </li>
                <li>
                  The script searches from left to right and stops
                  at the first match.
                </li>
              </ul>
            </td>
            <td style="width: 192.172px; height: 223px;">
              <ul>
                <li>Example: ['in_channel', 'utm_channel']</li>
                <li>
                  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.
                </li>
              </ul>
            </td>
          </tr>
          <tr style="height: 19px;">
            <td style="width: 139.969px; height: 19px;">
              <p>overrideValues</p>
            </td>
            <td style="width: 275.359px; height: 19px;">
              <ul>
                <li>Dictionary {string: string}</li>
                <li>
                  <span>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.</span>
                </li>
                <li>
                  The script replaces the param values of the incoming
                  URL with the values you define.&nbsp;
                </li>
              </ul>
            </td>
            <td style="width: 192.172px; height: 19px;">
              <p>Example: {'video': 'video_new'}</p>
              <p>
                For the channel parameter in the script, anytime
                the incoming value is video, the script changes it
                to video_new on the outgoing link.
              </p>
            </td>
          </tr>
          <tr style="height: 19px;">
            <td style="width: 139.969px; height: 19px;">defaultValue</td>
            <td style="width: 275.359px; height: 19px;">
              <ul>
                <li>String</li>
                <li>
                  <span>State what you want your "fallback" value to be.</span>
                </li>
                <li>
                  <span>If a parameter is not found from your key list, the defaultValue value is used in the outgoing URL.</span>
                </li>
                <li>
                  <span>You can force a default value by passing an empty keys list.</span>
                </li>
              </ul>
            </td>
            <td style="width: 192.172px; height: 19px;">
              <p>Example: ['web_video']</p>
              <p>
                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.
              </p>
            </td>
          </tr>
        </tbody>
      </table>
`}</HTMLBlock>

## Examples

### Basic attribution

See [example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/single_key.html?incmp=gogo\&inmedia=email) 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](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/multiple_keys.html?incmp11=gogo11\&inmedia22=email22) of the conversion of an incoming URL to an outgoing OneLink URL, with multiple keys for media\_source and campaign.

### UTM parameters

See [example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/utm_parameters.html?utm_campaign=mycmpn\&utm_source=mysource) of the conversion of an incoming URL to an outgoing OneLink URL, with UTM parameters for media\_source and campaign.

### Override values

See [example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/override_mediasource.html?inmedia=old_value) of the conversion of an incoming URL to an outgoing OneLink URL, replacing the incoming media\_source value.

### Default values

See [example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/override_mediasource.html?inmedia_found=orig_media_value) 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](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/forced_default_values.html?inmedia_found=plain_media_source) 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.

### GBRAID and WBRAID

See [example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/google_gbraid.html?inmedia=email\&gbraid=1a2b3c) of the conversion of an incoming URL to an outgoing OneLink URL, passing the `gbraid` parameter and [another example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/google_wbraid.html?inmedia=email\&wbraid=7hjy89) for passing the `wbraid` parameter.

### Google click ID passthrough

See [example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/google_clickid.html?inmedia=email\&gclid=1a2b3c\&keyword=sale%2Bboat) of the conversion of an incoming URL to an outgoing OneLink URL that passes the Google click ID to `af_sub4` and `gclid`.
As of Smart Script version 2.8.1, the GCLID is automatically forwarded to the outgoing URL when present in the incoming URL.
**Note:** When a GCLID is detected, the script searches for the incoming `keyword` parameter, and inserts its value into the outgoing URL as the value for the `af_keywords` parameter.

### Facebook click ID passthrough

See [example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/facebook_clickid.html?inmedia=email\&fbclid=7hjy89) of the conversion of an incoming URL to an outgoing OneLink URL that passes the Facebook click ID to `af_sub2` and `fbclid`.
As of Smart Script version 2.8.1, the FBCLID is automatically forwarded to the outgoing URL when present in the incoming URL.

### TikTok, X (formerly Twitter), Snap click ID passthrough

As of Smart Script version 2.10.0, the following Click ID parameters, when available, are automatically forwarded on outgoing URLs generated by the Smart Script:

* TikTok: `ttclid`
* X (formerly Twitter): `twclid`
* Snap: `ScCid`

### Set attribution and OneLink parameters

See [example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/onelink_parameters.html?inmedia=email\&dp_dest=apples\&inchnl=this_channel\&promo=buy99) of the conversion of an incoming URL to an outgoing OneLink URL with AppsFlyer attribution and OneLink parameters.

### Set additional custom parameters

See [example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/onelink_custom_parameters.html?inmedia=email\&dp_dest=apples\&pageid=2g4f\&productid=shirt12\&partner=bigagency) of the conversion of an incoming URL to an outgoing OneLink URL with additional custom parameters.

### Referrer skip list

See [example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/referrer_skip_list.html?incmp=gogo\&inmedia=email) of how you can disable the Smart Script for a particular click (for example, from Twitter or Meta ads) 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](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/url_skip_list.html?incmp=gogo\&inmedia=email\&af_r=hotel.me) 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](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/google_tag_manager.html?my_source=email\&app_dest=planes\&typeid=b787\&msg_id=f7h8) of the conversion of an incoming URL to an outgoing OneLink URL using OneLink Smart Script set up using Google Tag Manager.

### Impressions - OneLink Template with mobile-only support

See [example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/impressions_mobile.html?incmp=gogo\&inmedia=email) of an impressions fired using a OneLink template who has only mobile device.

<Callout icon="🚧" theme="warn">
  ### A must-do workaround

  Please wrap the call to `fireImpressionsLink` with `setTimeout` to make sure there is at least 1 second of delay between the call to `generateOneLinkURL` and `fireImpressionsLink`
</Callout>

### Impressions -  OneLink Template with Cross-platform support

See [example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/impressions_cross_platform.html?incmp=gogo\&inmedia=email) of an impressions fired using a OneLink template who has cross-platform support.<br />For example an impression fired from a non-mobile platform (e.g desktop or console).

<Callout icon="📘" theme="info">
  ### Firing an impression from a cross platform landing page

  You can find here a [code example](https://github.com/AppsFlyerSDK/appsflyer-sample-app-smartscript-demo-page/blob/8c0b6e7385b3b0cedd1208a530f002438a336e76/index.html#L241-L244) for firing an impression from a [demo landing page](https://appsflyersdk.github.io/appsflyer-sample-app-smartscript-demo-page/)
</Callout>

<Callout icon="🚧" theme="warn">
  ### Required: enable cross-platform attribution

  To fire an impression from a non-mobile platform, add the `af_xplatform` custom parameter to `afCustom` in your `afParameters` object, with a default value of `"true"`:

  ```javascript
  var afParameters = {
    ...
    afCustom: [
      { paramKey: "af_xplatform", keys: [], defaultValue: "true" },
    ],
  };
  ```

  This parameter is only required when calling `generateOneLinkURL` to fire an impression. Omit it when calling `generateDirectClickURL` to generate the install link itself.
</Callout>

<Callout icon="🚧" theme="warn">
  ### A must-do workaround

  Please wrap the call to `fireImpressionsLink` with `setTimeout` to make sure there is at least 1 second of delay between the call to `generateOneLinkURL` and `fireImpressionsLink`
</Callout>

### Preserve incoming URL parameters across pages

<Callout icon="📘" theme="info">
  Available from version 2.5.0.
</Callout>

Incoming parameters (e.g. `utm_source`) from a landing page are not passed to other pages in the website by default.<br />Importing Smart Script in every website page preserves the incoming URL parameters, and allows Smart Script to use them in other pages.

You can find here [an example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/save_params_demo/save_params_demo_home.html?utm_source=my_source\&utm_channel=my_channel) of this use case.

### Copy HTTP referrer to outgoing URL

<Callout icon="📘" theme="info">
  Available from version 2.7.0.
</Callout>

You can set Smart Script to copy the HTTP `document.referrer` to either a custom outgoing URL parameter or predefined outgoing URL parameters. If you want to see web referrer values in dashboards or in raw data reports, we suggest using one of the following **predefined** outgoing URL parameters:

* `af_channel` - Parameter is available in dashboards and raw data
* `af_sub1-5` - The parameter is available in raw data under the **af\_sub1-5** columns and in the **original URL** column.

If you want to set a custom parameter, Smart Script has to copy the   `document.referrer` property value and set it as the value of the parameter. In this [example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/webreferrer.html?utm_source=my_source\&utm_channel=my_channel),  Smart Script copies the `document.referrer` value to a custom outgoing URL parameter key defined by `webReferrer`. The selected custom key in the example is `this_referrer`.

For more information, see [Web referrer mapping](https://support.appsflyer.com/hc/en-us/articles/4413588932241-OneLink-Smart-Script-V2-setup#web-referrer-mapping).

### Utilizing Local Storage to Set Parameters for Deep Linking

You can choose to save any data from the website to local storage, and then configure Smart Script to retrieve this data and assign it to an outgoing URL parameter. For example, you can leverage website information to dynamically populate the `deep_link_value` parameter, enabling the deep linking of users directly to the app's relevant content.

In [this example](https://appsflyersdk.github.io/appsflyer-onelink-smart-script/examples/key_from_local_storage.html?incmp11=gogo11\&inmedia22=email22), you can see how the outgoing URL `deep_link_value` is populated by a value copied from the website's local storage. The copied value in this example is the product ID arriving from the website data.