• Developers Guide
  • SDK Integration
  • Web SDK

Web SDK

Install Web SDK

Install the Airbridge Web SDK using one of the methods below.

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
interface InitializeOptions { app: string webToken: string autoStartTrackingEnabled?: boolean utmParsing?: boolean utmParameterValueReplaceMap?: Record<string, Record<string, string>> urlQueryMapping?: Record<string, string> userHash?: boolean cookieWindow?: number cookieWindowInMinutes?: number useProtectedAttributionWindow?: boolean protectedAttributionWindowInMinutes?: number shareCookieSubdomain?: boolean collectMolocoCookieID?: boolean}

Verify Installation

Navigate to the page where the Airbridge Web SDK is installed, open the developer tools, and run the following code.

console.log(airbridge.isSDKEnabled)

If true is printed after running the code above, the SDK has been installed and initialized successfully.

Attention

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

setTimeout(function () { console.log(airbridge.isSDKEnabled)}, 5000)

Opt-in setup

Note

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

    airbridge.init({ app: 'YOUR_APP_NAME', webToken: 'YOUR_WEB_TOKEN', // ... autoStartTrackingEnabled: false,})
  2. 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.

    airbridge.startTracking()

Opt-out setup

Note

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

    airbridge.init({ app: 'YOUR_APP_NAME', webToken: 'YOUR_WEB_TOKEN', // ... autoStartTrackingEnabled: true,})
  2. 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.

    airbridge.stopTracking()

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.

airbridge.events.send('category', { label: 'Tool', action: 'Hammer', value: 10, semanticAttributes: { currency: 'USD', transactionID: 'transaction_123', products: [ { productID: 'coke_zero', name: 'PlasticHammer', }, ], }, customAttributes: { promotion: 'FirstPurchasePromotion', },})

Refer to the component definition and available strings below.

Additional web event settings

Note

Optional setting. Configure only if necessary.

Configure additional settings for sending web events if necessary.

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.

Custom Events are events defined by Airbridge users to track user actions that are unique to their services.
Refer to the example code below.

airbridge.events.send('category', { label: 'label', action: 'action', value: 10, semanticAttributes: { transactionID: 'transaction_123', }, customAttributes: { key: 'value', }})

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.

// IDairbridge.setUserID('testID')airbridge.clearUserID() // aliasairbridge.setUserAlias('ADD_YOUR_KEY', 'value')airbridge.removeUserAlias('DELETE_THIS_KEY')airbridge.clearUserAlias()

Set up user properties

Attention

Sensitive user information may be included. Send after a thorough review with a legal advisor.

By setting user properties, you can send additional user information.

// Automatically hashed on client side using SHA256// Can turn off hashing feature with special flagairbridge.setUserEmail('testID@ab180.co')airbridge.setUserPhone('821012341234') // attributesairbridge.setUserAttribute('ADD_YOUR_KEY', 1)airbridge.setUserAttribute('ADD_YOUR_KEY', 1.0)airbridge.setUserAttribute('ADD_YOUR_KEY', '1')airbridge.setUserAttribute('ADD_YOUR_KEY', true)airbridge.removeUserAttribute('DELETE_THIS_KEY')airbridge.clearUserAttributes()

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.

airbridge.init({ app: '<YOUR_APP_NAME>', webToken: '<YOUR_WEB_TOKEN?', // ... userHash: false, // Default true})

Clear user data

Use the clearUser function to clear user data.

airbridge.clearUser()

Web-to-App Setup

The Airbridge Web SDK supports deep linking, which allows you to pass attribution data from the web to the app. It also enables passing attribution data from one web session to another, without involving an app.

Create smart app banners

You can use the openBanner function to display a smart banner that encourages web users to install your app. By implementing various options, you can customize the banner’s title, description, button color and text, and enable Web-to-App, Web-to-Store, or Web-to-Web tracking.

공통 옵션

Web-to-App setup

If the type of the destination option is set to deeplink, clicking the banner button will open the app.

airbridge.openBanner({ title: '<BANNER_TITLE>', description: '<BANNER_DESCRIPTION>', buttonText: '<BANNER_BUTTON_TEXT>', color: '<BANNER_BUTTON_COLOR>', position: '<BANNER_POSITION>', // 'top' or 'bottom' destination: { type: 'deeplink', deeplinks: { android: '<YOUR_SCHEME>://...', ios: '<YOUR_SCHEME>://...', desktop: 'https://www.example.com/' }, fallbacks: { android: 'google-play', ios: 'itunes-appstore', }, }, ctaParams: { cta_param_1: '<EXAMPLE_CTA_PARAM_1>', cta_param_2: '<EXAMPLE_CTA_PARAM_2>', cta_param_3: '<EXAMPLE_CTA_PARAM_3>', }, defaultParams: { campaign: '<EXAMPLE_CAMPAIGN>', medium: '<EXAMPLE_MEDIUM>', term: '<EXAMPLE_TERM>', content: '<EXAMPLE_CONTENT>', },})

Web-to-Store setup

If the type of the destination option is set to download, clicking the banner button will open the app store.

airbridge.openBanner({ title: '<BANNER_TITLE>', description: '<BANNER_DESCRIPTION>', buttonText: '<BANNER_BUTTON_TEXT>', color: '<BANNER_BUTTON_COLOR>', position: '<BANNER_POSITION>', // 'top' or 'bottom' destination: { type: 'download', }, ctaParams: { cta_param_1: '<EXAMPLE_CTA_PARAM_1>', cta_param_2: '<EXAMPLE_CTA_PARAM_2>', cta_param_3: '<EXAMPLE_CTA_PARAM_3>', }, defaultParams: { campaign: '<EXAMPLE_CAMPAIGN>', medium: '<EXAMPLE_MEDIUM>', term: '<EXAMPLE_TERM>', content: '<EXAMPLE_CONTENT>', },})

Web-to-Web setup

If the type of the destination option is set to web, clicking the banner button will navigate the user to a specified website.

airbridge.openBanner({ title: '<BANNER_TITLE>', description: '<BANNER_DESCRIPTION>', buttonText: '<BANNER_BUTTON_TEXT>', color: '<BANNER_BUTTON_COLOR>', position: '<BANNER_POSITION>', // 'top' or 'bottom' destination: { type: 'web', url: 'https://www.example.com', }, ctaParams: { cta_param_1: '<EXAMPLE_CTA_PARAM_1>', cta_param_2: '<EXAMPLE_CTA_PARAM_2>', cta_param_3: '<EXAMPLE_CTA_PARAM_3>', }, defaultParams: { campaign: '<EXAMPLE_CAMPAIGN>', medium: '<EXAMPLE_MEDIUM>', term: '<EXAMPLE_TERM>', content: '<EXAMPLE_CONTENT>', },})

Custom style setup

You can customize the banner's appearance by adding a styles field to the options.

Each key should be specified using a CSS selector format, and each value should follow the CSSStyleDeclaration (TypeScript) format.

See the example below, which changes the border-radius of the icon area.

airbridge.openBanner({ ... styles: { '#airbridge-banner-icon': { borderRadius: '4px' } }})

Below is a list of IDs that can be used to apply CSS styles. You can specify the CSS style using a CSS selector format (e.g., #airbridge-banner-icon).

Implement a custom banner

The Airbridge Web SDK offers features to support custom banner implementation. If you want to add deep linking to an existing banner or build a more advanced custom banner, refer to the following information.

Web-to-App setup

You can use the openDeeplink function to open the app via a deep link.

Refer to the example below.

airbridge.openDeeplink({ deeplinks: { // Please use the custom scheme URL like `<YOUR_SCHEME>://...` // Don't use the `intent://...`, `market://...` or `https://...` android: '<YOUR_SCHEME>://path?key=value', // Please use the custom scheme URL like `<YOUR_SCHEME>://...` // Don't use the `intent://...`, `market://...` or `https://...` ios: '<YOUR_SCHEME>://path?key=value', desktop: 'https://www.example.com/path?key=value', }, fallbacks: { // Please use `google-play` or website URL like `https://www.example.com/...`. // Don't use the store URL like `https://play.google.com/...` android: 'google-play', // Please use `itunes-appstore` or website URL like `https://www.example.com/...`. // Don't use the store URL like `https://apps.apple.com/...` ios: 'itunes-appstore', }, ctaParams: { cta_param_1: '<EXAMPLE_CTA_PARAM_1>', cta_param_2: '<EXAMPLE_CTA_PARAM_2>', cta_param_3: '<EXAMPLE_CTA_PARAM_3>', }, defaultParams: { campaign: '<EXAMPLE_CAMPAIGN>', medium: '<EXAMPLE_MEDIUM>', term: '<EXAMPLE_TERM>', content: '<EXAMPLE_CONTENT>', },})

Attention

Make sure to use the deep link scheme URLs configured in the Airbridge dashboard for both deeplinks.android and deeplinks.ios.

  • <YOUR_SCHEME>://...

Never use the following types of URLs: Intent scheme URLs or HTTP/HTTPS URLs.

  • intent://...

  • market://...

  • https://www.example.com

Refer to the examples for tracking button-clicking events.

<button id="<BUTTON_ID>">앱으로 보기</button><script> document.querySelector('#<BUTTON_ID>').addEventListener('click', () => { airbridge.openDeeplink({ ... }) })</script>

Attention

Make sure to replace <BUTTON_ID> in the example with the actual ID of the button that should trigger the deep link when the user clicks it.

Web-to-Store setup

If you don’t input the deeplinks option in the openDeeplink function and set the fallbacks option to store, the app store will open regardless of whether the app is installed.

Refer to the example below.

airbridge.openDeeplink({ fallbacks: { android: 'google-play', ios: 'itunes-appstore', }, defaultParams: { campaign: '<EXAMPLE_CAMPAIGN>', medium: '<EXAMPLE_MEDIUM>', term: '<EXAMPLE_TERM>', content: '<EXAMPLE_CONTENT>', }, ctaParams: { cta_param_1: '<EXAMPLE_CTA_PARAM_1>', cta_param_2: '<EXAMPLE_CTA_PARAM_2>', cta_param_3: '<EXAMPLE_CTA_PARAM_3>', },})

Refer to the examples for configuring buttons.

<button id="<BUTTON_ID>">앱 다운로드하기</button><script> document.querySelector('#<BUTTON_ID>').addEventListener('click', () => { airbridge.openDeeplink({ ... }) })</script>

Attention

Make sure to replace <BUTTON_ID> in the example with the actual ID of the button that should trigger the deep link when the user clicks it.

Web-to-Web setup

If you don’t input the deeplinks option in the openDeeplink function and set the fallbacks option to URL, the user will be redirected to the website regardless of whether the app is installed.

Refer to the example below.

airbridge.openDeeplink({ fallbacks: { android: 'https://www.example.com', ios: 'https://www.example.com', }, defaultParams: { campaign: '<EXAMPLE_CAMPAIGN>', medium: '<EXAMPLE_MEDIUM>', term: '<EXAMPLE_TERM>', content: '<EXAMPLE_CONTENT>', }, ctaParams: { cta_param_1: '<EXAMPLE_CTA_PARAM_1>', cta_param_2: '<EXAMPLE_CTA_PARAM_2>', cta_param_3: '<EXAMPLE_CTA_PARAM_3>', },})

Refer to the examples for configuring buttons.

<button id="<BUTTON_ID>">웹으로 이동하기</button><script> document.querySelector('#<BUTTON_ID>').addEventListener('click', () => { airbridge.openDeeplink({ ... }) })</script>

Attention

Make sure to replace <BUTTON_ID> in the example with the actual ID of the button that should trigger the deep link when the user clicks it.

Note

The openDeeplink function is a unified replacement for the existing setDeeplinks, setDownloads, and sendWeb functions. It is a pure function that can be used independently, without needing to bind it to a DOM element, such as a button.

The setDeeplinks function will be maintained but no longer updated in future releases. Therefore, use the openDeeplink function to implement the features you need.

You can use the setDeeplinks function to assign deep link functionality to a button.

Refer to the example below.

<button id="<BUTTON_ID>">앱으로 보기</button><script> airbridge.setDeeplinks({ buttonID: '<BUTTON_ID>', // or ['<BUTTON_ID_1>', '<BUTTON_ID_2>', ...] deeplinks: { android: '<YOUR_SCHEME>://path?key=value', ios: '<YOUR_SCHEME>://path?key=value', desktop: 'https://www.example.com/path?key=value', }, fallbacks: { android: 'google-play', ios: 'itunes-appstore', }, defaultParams: { campaign: '<EXAMPLE_CAMPAIGN>', medium: '<EXAMPLE_MEDIUM>', term: '<EXAMPLE_TERM>', content: '<EXAMPLE_CONTENT>', }, ctaParams: { cta_param_1: '<EXAMPLE_CTA_PARAM_1>', cta_param_2: '<EXAMPLE_CTA_PARAM_2>', cta_param_3: '<EXAMPLE_CTA_PARAM_3>', }, })</script>

Attention

When using the setDeeplinks function, the Web SDK manages the button behavior internally, so do not set an onclick function on the button. Also, do not use the id of an <a> tag as the target element.

The openDeeplink function is a unified replacement for the existing setDeeplinks, setDownloads, and sendWeb functions. It is a pure function that can be used independently, without needing to bind it to a DOM element, such as a button.

The setDownloads function will be maintained but no longer updated in future releases. Therefore, use the openDeeplink function to implement the features you need.

You can use the setDownloads function to configure the store redirection functionality to a button.

JavaScript
<button id="<BUTTON_ID>">앱 다운로드하기</button><script> airbridge.setDownloads({ buttonID: '<BUTTON_ID>', // or ['<BUTTON_ID_1>', '<BUTTON_ID_2>', ...] defaultParams: { campaign: '<EXAMPLE_CAMPAIGN>', medium: '<EXAMPLE_MEDIUM>', term: '<EXAMPLE_TERM>', content: '<EXAMPLE_CONTENT>', }, ctaParams: { cta_param_1: '<EXAMPLE_CTA_PARAM_1>', cta_param_2: '<EXAMPLE_CTA_PARAM_2>', cta_param_3: '<EXAMPLE_CTA_PARAM_3>', }, })</script>

Attention

When using the setDownloads function, the Web SDK manages the button behavior internally, so do not set an onclick function on the button. Also, do not use the id of an <a> tag as the target element.

Pass attribution data to another website before redirecting

Attention

The openDeeplink function is a unified replacement for the existing setDeeplinks, setDownloads, and sendWeb functions. It is a pure function that can be used independently, without needing to bind it to a DOM element, such as a button.

The sendWeb function will be maintained but no longer updated in future releases. Therefore, use the openDeeplink function to implement the features you need.

You can use the sendWeb function to send users to a website on a different domain. In this case, attribution data can be passed across the websites.

airbridge.sendWeb('https://other.example.com')

If you input a callback function, users are not sent to the website immediately. The URL sent through the callback function can be used freely.

<button id="<BUTTON_ID>">웹으로 이동하기</button><script> document.querySelector('#<BUTTON_ID>').addEventListener('click', () => { airbridge.openDeeplink('https://other.example.com', (error, { targetUrl }) => { // Open the link with new window or tab. window.open(targetUrl) }) })</script>

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.

Attention

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

airbridge.init({ app: '<YOUR_APP_NAME>', webToken: '<YOUR_WEB_TOKEN>', // ... user: { externalUserID: 'personID', externalUserEmail: 'persondoe@airbridge.io', externalUserPhone: '1(123)123-1234', attributes: { age_group: 30, gender: 'Female' }, alias: { custom_id: '83587901-2726-4E29-ACEB-A90B0F7E75F6', }, },})

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.

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.

airbridge.events.send('category') airbridge.events.wait(3000, () => { location.href = '<TARGET_URL>'})

Edit the attribution window

You can set the attribution window in days using the cookieWindow option.
The default setting is 3 days.

airbridge.init({ app: '<YOUR_APP_NAME>', webToken: '<YOUR_WEB_TOKEN>', // ... cookieWindowInMinutes: <MINUTES>,})

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.

airbridge.init({ app: '<YOUR_APP_NAME>', webToken: '<YOUR_WEB_TOKEN>', // ... cookieWindow: <DAYS>,})

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.

airbridge.init({ app: 'YOUR_APP_NAME', webToken: 'YOUR_WEB_TOKEN', // ... useProtectedAttributionWindow: true,})

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.

airbridge.init({ app: '<YOUR_APP_NAME>', webToken: '<YOUR_WEB_TOKEN>', // ... useProtectedAttributionWindow: true, protectedAttributionWindowInMinutes: 60,})

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.

// initialize airbridge.init({ app: '<YOUR_APP_NAME>', webToken: '<YOUR_WEB_TOKEN>', // ... shareCookieSubdomain: false,})

Note

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

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.

// Subdomain #1: a.example.comairbridge.init({ app: '<YOUR_APP_NAME>', webToken: '<YOUR_WEB_TOKEN>', // ... useStoragePerApp: true,}) // Subdomain #2: b.example.comairbridge.init({ app: '<YOUR_ANOTHER_APP_NAME>', webToken: '<YOUR_ANOTHER_WEB_TOKEN>', // ... useStoragePerApp: true,})

Attention

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

interface Airbridge { createTrackingLink( channel: string, options: Record<string, boolean | number | string>, onSuccess: (trackingLink: TrackingLink) => void ): void createTrackingLink( channel: string, options: Record<string, boolean | number | string>, onSuccess: (trackingLink: TrackingLink) => void, onError: (error: Error) => void ): void}

Tracking links created using the createTrackingLink function are passed via the onSuccess callback.

interface TrackingLink { shortURL: string qrcodeURL: string}

When collectMolocoCookieID is set to true, the SDK automatically collects the cookie ID from events driven by Moloco web campaigns, enabling campaign optimization.

airbridge.init({ app: '<YOUR_APP_NAME>', webToken: '<YOUR_WEB_TOKEN>', // ... collectMolocoCookieID: true,})

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

customInstance.events.send('category', { label: 'Tool', action: 'Hammer', value: 10, semanticAttributes: { currency: 'USD', transactionID: 'transaction_123', products: [ { productID: 'coke_zero', name: 'PlasticHammer', }, ], }, customAttributes: { promotion: 'FirstPurchasePromotion', },})