Skip to main content

Install SDK

Install the Airbridge Web SDK using one of the methods below.
Add the code below to the bottom of the <head> section.
Run the commands below to install airbridge-web-sdk-loader.
If you install the airbridge-web-sdk-loader package, you can refer to the code below.
The app and webToken can be found in the Airbridge dashboard under Settings → Tokens.

Supported browser

The Airbridge Web SDK works on all browsers that support ES5.

SDK initialization

Initialize the Airbridge Web SDK using the airbridge.init() function. The app and webToken values required for initialization can be found in the Airbridge dashboard under Settings → Tokens. Additional initialization options can be configured as needed. The following is the type definition for the initialization settings.
JavaScript

Web SDK Options

Verify Installation

Navigate to the page where the Airbridge Web SDK is installed, open the developer tools, and run the following code.
If true is printed after running the code above, the SDK has been installed and initialized successfully.
Attentionairbridge.isSDKEnabled is initially false. It changes to true once the Web SDK is fully loaded and initialized successfully.Depending on the network environment, loading may be delayed, and if checked before loading is complete, false may be returned.
If you suspect that false is being printed due to network delay, run the code below in the developer tools to check the value after 5 seconds.

Opt-in setup

NoteOptional setting. Configure only if necessary.
The opt-in policy requires user consent before using user data. After setting the autoStartTrackingEnabled to false, call the startTracking function at the point where you can collect events. When the startTracking function is called, the SDK will start collecting events. The default setting is true.
  1. Prevent automatic event tracking after initialization through the autoStartTrackingEnabled.
  1. Collect user responses to the collection and use of personal information. If the user agrees to the collection and use of personal information, start tracking events.

Opt-out setup

NoteOptional setting. Configure only if necessary.
The opt-out policy allows the use of user information until the user explicitly declines. After setting the autoStartTrackingEnabled option to true, call the stopTracking function at the point where you can no longer collect events. When the stopTracking function is called, the SDK will stop collecting events.
  1. Enable automatic event tracking after initialization through the autoStartTrackingEnabled. Since the default value of the autoStartTrackingEnabled option is true, events are tracked automatically event if this setting is omitted.
  1. Collect user responses to the collection and use of personal information. If the user refuses the collection and use of personal information, stop tracking events.

Web Event

The Airbridge Web SDK collects user actions from the app as per settings and sends them as in-app events.

Send web events

Use the airbridge.events.send function to send events. Refer to the example below.
Refer to the component definition and available strings below.
Airbridge provides Standard Events. Refer to the list of Standard Events and send events accordingly.You can send a custom event by entering the event name set in the event taxonomy.
Additional information about the event can be collected using attributes.
  • action, label: Collect information that can be used as GroupBys in the Airbridge reports.
  • value: Collect information that can be used for sales analysis. Airbridge can perform calculations using the collected data.
  • Semantic Attribute: Collect predefined attributes by Airbridge.
  • Custom Attribute: Collect attributes defined by Airbridge users.
The semantic attributes predefined by Airbridge can be found in the user guide below.

Additional web event settings

NoteOptional setting. Configure only if necessary.
Configure additional settings for sending web events if necessary.
You can send additional user information when sending the events through the SDK.

Example codes

Airbridge collects in-app events that are classified as Standard Events and Custom Events. Standard Events. are events predefined by Airbridge. Refer to the example codes below.
Sign-up
Sign-in
Sign-out
Home Screen
Product Catalog
Search Results
Product View
Add Payment Info
Add to Wishlist
Add to Cart
Initiate Checkout
Order Complete
Order Cancel
AttentionFor Order Cancel events, make sure to enter the transactionID of the Order Cancel event into the transactionID field.If the transactionID values don’t match, the Order Cancel event won’t be processed properly.For more details, refer to the Collecting Order Cancel Events for Accurate Sales Performance Measurement.
Start Trial
Subscribe
Unsubscribe
Ad Impression
Ad Click
Complete Tutorial
Achieve Level
Unlock Achievement
Rate
Share
Schedule
Spend Credits
Custom Events are events defined by Airbridge users to track user actions that are unique to their services. Refer to the example code below.

User Data

Set up User ID

User IDs refer to the user identifier used in a service. User IDs should be unique IDs that can unique users across websites and apps. The user data you set is stored in the browser’s local storage and will be included in all events until it is cleared. Refer to the example below.

Set up user properties

AttentionSensitive user information may be included. Send after a thorough review with a legal advisor.
By setting user properties, you can send additional user information.
You can send user email addresses and phone numbers in hashed form. The default setting is true. The user ID is not affected by the hash option, so if hashing is required, you must hash the user ID yourself before assigning its value.

Clear user data

Use the clearUser function to clear user data.

Web-to-app setup

You can apply the openDeeplink function to a button on a web page to send users to the app. The function is typically used with a button, as shown below. Replace <BUTTON_ID> in the example code with the actual ID of the button that users click.
Refer to the example below for the openDeeplink function.
Use the deeplinks option to enter where to deep link users on each operating system and on desktop. All options are required.
AttentionFor deeplinks.android and deeplinks.ios, you must enter a URL scheme deep link in the appScheme://host/path format. Do not use intent scheme URLs or HTTP(S) URLs.

Fallback paths (required)

Use the fallbacks option to enter the fallback path to send users to on each operating system when deep linking fails. All options are required.
AttentionTo send users to the app store, enter 'google-play' in fallbacks.android and 'itunes-appstore' in fallbacks.ios as is. If you enter any other value, the fallback does not work as expected.

Type (required)

Use the type option to enter a value depending on whether the web page has a CTA element, such as a button. This option is required. Use ctaParams to enter the CTA button information to view in reports. All fields are optional. Ask your marketer for the information to enter. You can enter up to three fields per openDeeplink function. For accurate performance analysis, we recommend entering all three. You can define any button-related information in CTA Param. Refer to the examples below. You can also define items that are not listed.

Campaign information (optional)

NoteTouchpoint information is not collected when users reach the web landing page in the following ways. In these cases, the campaign information entered in defaultChannel and defaultParams appears in reports when you select a touchpoint group-by.
  • Users click an ad that has no tracking link or UTM parameters applied
  • Users enter the web landing page URL directly
Use defaultChannel and defaultParams to enter the campaign information to view in Airbridge reports. Ask your marketer for the information to enter. For details, see Set up campaign parameters.

Custom store page information (optional)

You can use options.androidStoreListing or options.iosStoreProductPage to set up a custom store page for the store fallback. For details on custom store pages, see the official documentation (Google Play Store, Apple App Store).
AttentionTo use the options.androidStoreListing option, set fallbacks.android to "google-play". To use the options.iosStoreProductPage option, set fallbacks.ios to "itunes-appstore".

Clipboard-based deferred deep linking (optional)

AttentionWeb browsers require a user action to access the clipboard. When clipboard-based deferred deep linking is set up, the Web SDK shows an alert just for the clipboard, which may degrade the user experience.
When the options.clipboardLink option is set to true, the openDeeplink function can be used for clipboard-based deferred deep linking. The default setting is false. Clipboard-based deferred deep linking is a feature that copies the deep link and attribution data to the clipboard from the tracking link that the user clicked, reads that data from the clipboard when the user opens the app for the first time, and enables deferred deep linking with them through a deterministic approach. For more details, see Clipboard Deferred Deep Linking.

Legacy functions

NoteThe openDeeplink function replaces the existing setDeeplinks, setDownloads, and sendWeb functions and can be used independently, without binding to a DOM element. The existing functions will no longer be updated in future releases. Therefore, we strongly recommend using the openDeeplink function. Refer to the information below only if you already use the existing functions.
You can use the setDownloads function to send users to the app store, regardless of whether the app is installed.Refer to the example below.
JavaScript
AttentionWhen using the setDownloads function, the Web SDK manages the button behavior internally, so never set an onclick function on the button. Also, do not use the id of an <a> tag.
You can use the sendWeb function to send users to another web page. Attribution data is passed between the web pages.
The function is typically used with a button, as shown below. If you input a callback function, users are not sent to the website immediately. You can use the URL passed to the callback function.

Create smart app banners

You can use the openBanner function to create a smart banner on a web page. Use the smart banner provided by Airbridge to add a banner to your web landing page. The image below shows the default smart banner format. You can change the title, description, button text, and more.
Default Airbridge smart banner with an icon, title, description, and open button
Enter the following fields to configure the banner.

Redirection information

Enter the destination field in the banner information to set where to redirect users who click the button. Deep link users to the app To deep link users to the app, configure the settings as follows. Refer to the example below.
Send users to the app store To send users on a web page to the app store, configure the settings as follows. Refer to the example below.
Send users to a web page To send users on a web page to another web page, configure the settings as follows. Refer to the example below.

Style information

Enter the styles field in the banner information to change the banner style. Each key should be specified using a CSS selector format. Use the id values provided by Airbridge below to specify which part of the banner to change. Each value should follow the CSSStyleDeclaration (TypeScript) format. Refer to the example below.

Additional settings

Compliance with Google DMA

To comply with the Digital Markets Act (DMA), the user consent data must be sent to Airbridge. For more information about the DMA and whether it applies to your service, refer to the Airbridge user guide.
AttentionAdvertisers must collect user consent data from all existing and new users in the EEA at least once starting March 6, 2024.
Refer to the following method.

Pass user data during initialization

You can pass user data during initialization so that all subsequent events include the user data. The user data you set is stored in the browser’s local storage and will be included in all events until it is cleared.

Set up campaign parameters

When users land on your website through an ad, you can append parameters to the URL to enable web traffic attribution based on that information.
When the utmParsing option is set to true, UTM-related parameters included in the URL are automatically extracted and attached to events. The default event is false.
AttentionThe URL must contain the utm_source parameter. Even if the utmParsing option is set to true, other UTM parameters are ignored when the utm_source parameter is not in the URL.
The utmParameterValueReplaceMap option allows you to replace the values of UTM parameters collected through the utmParsing option. Supported parameters include utm_source, utm_campaign, utm_medium, utm_term, and utm_content.By using utmParameterValueReplaceMap, you can align UTM parameter values collected from various sources, making it easier to analyze data consistently in a single dashboard.
In the example above, if the utm_source in the URL is before_replace (e.g., https://www.example.com/?utm_source=before_replace), the value will be replaced with after_replace and sent with the event.
By configuring the urlQueryMapping option, you can include non-UTM parameters as campaign parameters and send them with events.Let’s say, the following URL contains the utm_source, utm_campaign parameters and the my_sub_id parameter that is used within your service.
  • https://www.example.com/path?utm_source=my_channel&utm_campaign=my_campaign&my_sub_id=example
In this case, you can view sub_id_1 as my_sub_id in the Airbridge dashboard, along with utm_source and utm_parameter.
AttentionInput channel in the urlQueryMapping option. If not, all other options are also ignored.
You can manually parse the parameters and pass the information when calling the init function.Refer to the following example.

Set delay time to ensure event transmission

You can use the events.wait function to ensure that all event transmissions are completed before the user navigates away. If a page is navigated away before the events are fully transmitted, there is a risk of event data loss. For example, when transmitting event data on an intermediate page that quickly redirects, use events.wait and minimize the risk of data loss.

Edit the attribution window

You can set the attribution window in days using the cookieWindow option. The default setting is 3 days.
You can also set the attribution window in minutes using the cookieWindowInMinutes option. If both cookieWindow option and cookieWindowInMinutes option are configured, the cookieWindowInMinutes option takes precedence.

Set the attribution window for web-to-app attribution

You can configure the Protected Attribution Window (PAW) using the useProtectedAttributionWindow option. The default setting is true.
  • When useProtectedAttributionWindow is set to true, PAW is applied. For more details, refer to the User Guide.
  • When useProtectedAttributionWindow is set to false, PAW is not applied. For more details, refer to the User Guide.
You can set the Protected Attribution Window (PAW) in minutes using the protectedAttributionWindowInMinutes option. The default value is 30 minutes, and it can be set up to a maximum of 3 days (4320 minutes). This option is only enabled when useProtectedAttributionWindow is set to true.

Share attribution data across subdomains

By default, the Airbridge Web SDK stores attribution data in cookies and uses the root domain’s cookie storage. This allows attribution data to be shared across subdomains. If you’re using multiple subdomains, you can configure whether to share cookies between them using the shareCookieSubdomain option. When shareCookieSubdomain is set to false, data will not be shared between subdomains. The default setting is true.
NoteConfigure the setting based on the following scenarios:
  • Set to true if you are operating a single service across multiple subdomains.
  • Set to false if you are operating different services on each subdomain.
Let’s assume the following scenario:
  1. A user clicks a tracking link for Campaign A and lands on https://www.airbridge.io .
  2. The user then clicks a link on the site and is redirected to https://blog.airbridge.io .
In this case, the attribution result will differ depending on the shareCookieSubdomain setting:
  • true
    • https://www.airbridge.io → Attributed to Campaign A
    • https://blog.airbridge.io → Attributed to Campaign A
  • false
    • https://www.airbridge.io → Attributed to Campaign A
    • https://blog.airbridge.io → Unattributed
The unattributed case assumes that the Web SDK is installed on https://blog.airbridge.io, and that no specific campaign parameter options were added to the init function.Attribution is determined by the internal logic of the Web SDK based on the options set in the init function.

Separate storage by app

By default, the Airbridge Web SDK is designed to store attribution data for only one app per domain. When the useStoragePerApp option is set to true, data storage is separated, allowing multiple apps using subdomains under the same root domain to manage attribution data independently. The default setting is false. For example, if multiple apps are used on subdomains that share the same root domain, such as a.example.com and b.example.com under example.com, you can separate the storage by enabling the useStoragePerApp option as shown below.
AttentionIf you change the useStoragePerApp option, the first event triggered in each browser immediately after the change may be unattributed.
You can create a tracking link using the createTrackingLink function. A tracking link is a URL created to transmit touchpoint data generated by users to Airbridge. With tracking links, you can direct users who have viewed or clicked on an ad to a desired destination. In the Airbridge dashboard, you can use the touchpoint data collected from these tracking links to analyze which channels contributed to conversions.
Tracking links created using the createTrackingLink function are passed via the onSuccess callback.
When collectMolocoCookieID is set to true, the SDK automatically collects the cookie ID from events driven by Moloco web campaigns, enabling campaign optimization.

Using multiple apps

By defaults, the Airbridge Web SDK is accessed via a global airbridge object. However, certain use cases may require the use of independent SDK instances. The Airbridge Web SDK supports the simultaneous use of multiple Airbridge apps within a single service. You can create new, isolated instances using the createAirbridge function.

Instance creation and initialization

Both the global airbridge object and any other instances created via createAirbridge are fully isolated. This allows all SDK features, including initialization, to be managed and executed separately for each instance.

Send web events