• Developers Guide
  • SDK Integration
  • Web SDK

Web SDK

Install Web SDK

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

Add the code below to the bottom of the <head> section.

12345678
<script>
(function(a_,i_,r_,_b,_r,_i,_d,_g,_e){function q(b,a){function d(){var l=x(b,a);y(l)}if(0<_g){var e,f=new (null!=(e=a_.XDomainRequest)?e:a_.XMLHttpRequest);e=function(){};f.open("GET",a);f.timeout=_g;f.onload=d;f.onerror=e;f.onprogress=e;f.ontimeout=e;f.send()}else d()}function y(b){if("complete"===i_.readyState)i_.head.appendChild(b);else{var a=function(){a_.removeEventListener("load",a);i_.head.appendChild(b)};a_.addEventListener("load",a)}}function x(b,a){var d=i_.createElement(r_);d.async=!0;d.src=a;d.onerror=function(){return z(b)};return d}function z(b){b.queue.filter(function(a){return 0<=_d.indexOf(a[0])}).forEach(function(a){a=a[1];a=a[a.length-1];"function"===typeof a&&a("Failed to load Airbridge SDK.")})}function r(b){var a={queue:null!=b?b:[],get isSDKEnabled(){return!1}};_i.concat(_d).forEach(function(d){var e=d.split("."),f=e.pop();e.reduce(function(l,t){var u;return l[t]=null!=(u=l[t])?u:{}},a)[f]=function(){a.queue.push([d,arguments])}});return a}null!=a_.__AIRBRIDGE__||(a_.__AIRBRIDGE__={mocks:[]});"undefined"!==typeof i_.documentMode&&(_r=_r.replace(/^https:/,""));a_.createAirbridge=function(){var b=r(),a;null==(a=a_.__AIRBRIDGE__)||a.mocks.push(b);q(b,_r);return b};a_[_b]||(_e=r(_e),a_[_b]=_e,q(_e,_r))})(window,document,"script","airbridge","https://static.airbridge.io/sdk/latest/airbridge.min.js","init startTracking stopTracking openBanner setBanner setDownload setDownloads openDeeplink setDeeplinks sendWeb setUserAgent setMobileAppData setUserID clearUserID setUserEmail clearUserEmail setUserPhone clearUserPhone setUserAttribute removeUserAttribute clearUserAttributes setUserAlias removeUserAlias clearUserAlias clearUser setUserId setUserAttributes addUserAlias setDeviceAlias removeDeviceAlias clearDeviceAlias setDeviceIFV setDeviceIFA setDeviceGAID events.send events.signIn events.signUp events.signOut events.purchased events.addedToCart events.productDetailsViewEvent events.homeViewEvent events.productListViewEvent events.searchResultViewEvent".split(" "),["events.wait","fetchResource","createTouchpoint","createTrackingLink"],0);

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

Run the commands below to install airbridge-web-sdk-loader.

1
npm install airbridge-web-sdk-loader
1
yarn add airbridge-web-sdk-loader
1
pnpm i airbridge-web-sdk-loader

If you install the airbridge-web-sdk-loader package, you can refer to the code below.

123456
import airbridge from 'airbridge-web-sdk-loader'

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

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
123456789101112131415
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
}

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.

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

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

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

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

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

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

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

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

Note

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

123
airbridge.setDeviceAlias('<DEVICE_ALIAS_KEY>', '<DEVICE_ALIAS_VALUE>')
airbridge.removeDeviceAlias('<DEVICE_ALIAS_KEY>')
airbridge.clearDeviceAlias()

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

123456789
// Make sure to set user information before sending the event
airbridge.setUserID('string')
airbridge.setUserPhone('string')
airbridge.setUserEmail('string')
airbridge.setUserAttribute('string', 'string')
airbridge.setUserAlias('string', 'string')

// Send event
airbridge.events.send('airbridge.user.signup')

Sign-in

123456789
// Make sure to set user information before sending the event
airbridge.setUserID('string')
airbridge.setUserPhone('string')
airbridge.setUserEmail('string')
airbridge.setUserAttribute('string', 'string')
airbridge.setUserAlias('string', 'string')

// Send event
airbridge.events.send('airbridge.user.signin')

Sign-out

12345
// Send event before clearing user information
airbridge.events.send('airbridge.user.signout')

// Initialize user information
airbridge.clearUser()

Home Screen

1
airbridge.events.send('airbridge.ecommerce.home.viewed')

Product Catalog

12345678910111213141516171819202122
airbridge.events.send('airbridge.ecommerce.product.viewed', {
    semanticAttributes: {
        listID: '84e6e236-38c4-48db-9b49-16e4cc064386',
        currency: 'USD',
        products: [
            {
                productID: '0117b32a-5a6c-4d4c-b64c-7858e07dba78',
                name: 'PlasticHammer',
                price: 10,
                quantity: 1,
                currency: 'USD',
            },
            {
                productID: 'd6ab2fbe-decc-4362-b719-d257a131e91e',
                name: 'PlasticFork',
                price: 1,
                quantity: 1,
                currency: 'USD',
            },
        ],
    },
})

Search Results

12345678910111213141516171819202122
airbridge.events.send('airbridge.ecommerce.searchResults.viewed', {
    semanticAttributes: {
        query: 'Plastic',
        currency: 'USD',
        products: [
            {
                productID: '0117b32a-5a6c-4d4c-b64c-7858e07dba78',
                name: 'PlasticHammer',
                price: 10,
                quantity: 1,
                currency: 'USD',
            },
            {
                productID: 'd6ab2fbe-decc-4362-b719-d257a131e91e',
                name: 'PlasticFork',
                price: 1,
                quantity: 1,
                currency: 'USD',
            },
        ],
    },
})

Product View

123456789101112131415161718
airbridge.setUserID('string')
airbridge.setUserPhone('string')
airbridge.setUserEmail('string')
airbridge.setUserAttribute('string', 'string')
airbridge.setUserAlias('string', 'string')

airbridge.events.send('airbridge.ecommerce.product.viewed', {
    semanticAttributes: {
        currency: 'USD',
        products: [{
            productID: '0117b32a-5a6c-4d4c-b64c-7858e07dba78',
            name: 'PlasticHammer',
            price: 10,
            quantity: 1,
            currency: 'USD',
        }],
    },
})

Add Payment Info

12345
airbridge.events.send('airbridge.addPaymentInfo', {
    semanticAttributes: {
        type: 'CreditCard',
    },
})

Add to Wishlist

12345678910111213
airbridge.events.send('airbridge.addToWishlist', {
    semanticAttributes: {
        listID: '189a2f8b-83ee-4074-8158-726be54e57d4',
        currency: 'USD',
        products: [{
            productID: '0117b32a-5a6c-4d4c-b64c-7858e07dba78',
            name: 'PlasticHammer',
            price: 10,
            quantity: 1,
            currency: 'USD',
        }],
    },
})

Add to Cart

12345678910111213
airbridge.events.send('airbridge.ecommerce.product.addedToCart', {
    semanticAttributes: {
        cartID: '421eaeb7-6e80-4694-933e-f2e1a55e9cbd',
        currency: 'USD',
        products: [{
            productID: '0117b32a-5a6c-4d4c-b64c-7858e07dba78',
            name: 'PlasticHammer',
            price: 10,
            quantity: 1,
            currency: 'USD',
        }],
    },
})

Initiate Checkout

12345678910111213141516171819202122
airbridge.events.send('airbridge.initiateCheckout', {
    semanticAttributes: {
        transactionID: '0a7ee1ec-33da-4ffb-b775-89e80e75978a',
        currency: 'USD',
        products: [
            {
                productID: '0117b32a-5a6c-4d4c-b64c-7858e07dba78',
                name: 'PlasticHammer',
                price: 10,
                quantity: 1,
                currency: 'USD',
            },
            {
                productID: 'd6ab2fbe-decc-4362-b719-d257a131e91e',
                name: 'PlasticFork',
                price: 1,
                quantity: 1,
                currency: 'USD',
            },
        ],
    },
})

Order Complete

123456789101112131415161718192021222324
airbridge.events.send('airbridge.ecommerce.order.completed', {
    value: 11,
    semanticAttributes: {
        transactionID: '8065ef16-162b-4a82-b683-e51aefdda7d5',
        currency: 'USD',
        inAppPurchased: true,
        products: [
            {
                productID: '0117b32a-5a6c-4d4c-b64c-7858e07dba78',
                name: 'PlasticHammer',
                price: 10,
                quantity: 1,
                currency: 'USD',
            },
            {
                productID: 'd6ab2fbe-decc-4362-b719-d257a131e91e',
                name: 'PlasticFork',
                price: 1,
                quantity: 1,
                currency: 'USD',
            },
        ],
    },
})

Order Cancel

Attention

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

123456789101112131415161718192021222324
airbridge.events.send('airbridge.ecommerce.order.canceled', {
    value: 11,
    semanticAttributes: {
        transactionID: '8065ef16-162b-4a82-b683-e51aefdda7d5',
        currency: 'USD',
        inAppPurchased: true,
        products: [
            {
                productID: '0117b32a-5a6c-4d4c-b64c-7858e07dba78',
                name: 'PlasticHammer',
                price: 10,
                quantity: 1,
                currency: 'USD',
            },
            {
                productID: 'd6ab2fbe-decc-4362-b719-d257a131e91e',
                name: 'PlasticFork',
                price: 1,
                quantity: 1,
                currency: 'USD',
            },
        ],
    },
})

Start Trial

12345678910111213
airbridge.events.send('airbridge.startTrial', {
    semanticAttributes: {
        transactionID: 'ef1e5271-0370-407c-b1e9-669a8df1dc2c',
        currency: 'USD',
        period: 'P1M',
        products: [{
            productID: '306a57cb-f653-4220-a208-8405d8e4d506',
            name: 'MusicStreamingMembership',
            price: 15,
            currency: 'USD',
        }],
    },
})

Subscribe

123456789101112131415
airbridge.events.send('airbridge.subscribe', {
    value: 15,
    semanticAttributes: {
        currency: 'USD',
        transactionID: 'cbe718c7-e44e-4707-b5cd-4a6a29f29649',
        period: 'P1M',
        isRenewal: true,
        products: [{
            productID: '306a57cb-f653-4220-a208-8405d8e4d506',
            name: 'MusicStreamingMembership',
            price: 15,
            currency: 'USD',
        }],
    },
})

Unsubscribe

123456789101112131415
airbridge.events.send('airbridge.unsubscribe', {
    value: 15,
    semanticAttributes: {
        currency: 'USD',
        transactionID: 'cbe718c7-e44e-4707-b5cd-4a6a29f29649',
        period: 'P1M',
        isRenewal: true,
        products: [{
            productID: '306a57cb-f653-4220-a208-8405d8e4d506',
            name: 'MusicStreamingMembership',
            price: 15,
            currency: 'USD',
        }],
    },
})

Ad Impression

1234567891011121314151617181920212223
airbridge.events.send('airbridge.adImpression', {
    value: 0.01,
    semanticAttributes: {
        adPartners: [{
            app_version: '5.18.0',
            adunit_id: '12345',
            adunit_name: '12345',
            adunit_format: 'Banner',
            id: '12345',
            currency: 'USD',
            publisher_revenue: 12345.123,
            adgroup_id: '12345',
            adgroup_name: '12345',
            adgroup_type: '12345',
            adgroup_priority: '12345',
            country: 'kr',
            precision: 'publisher_defined',
            network_name: '12345',
            network_placement_id: '12345',
            demand_partner_data: '12345',
        }],
    },
})

Ad Click

1234567891011121314151617181920212223
airbridge.events.send('airbridge.adClick', {
    value: 0.1,
    semanticAttributes: {
        adPartners: [{
            app_version: '5.18.0',
            adunit_id: '12345',
            adunit_name: '12345',
            adunit_format: 'Banner',
            id: '12345',
            currency: 'USD',
            publisher_revenue: 12345.123,
            adgroup_id: '12345',
            adgroup_name: '12345',
            adgroup_type: '12345',
            adgroup_priority: '12345',
            country: 'kr',
            precision: 'publisher_defined',
            network_name: '12345',
            network_placement_id: '12345',
            demand_partner_data: '12345',
        }],
    },
})

Complete Tutorial

12345
airbridge.events.send('airbridge.completeTutorial', {
    semanticAttributes: {
        description: 'Finish Initial Tutorial',
    },
})

Achieve Level

12345
airbridge.events.send('airbridge.achieveLevel', {
    semanticAttributes: {
        level: 13,
    },
})

Unlock Achievement

1234567
airbridge.events.send('airbridge.unlockAchievement', {
    semanticAttributes: {
        achievementID: '36a0f0bb-b153-4be1-a3e0-3cb5b2b076c1'
        description: 'Finish Initial Tutorial',
        score: 80,
    },
})

Rate

1234567891011121314
airbridge.events.send('airbridge.rate', {
    semanticAttributes: {
        rateID: '531c64b3-4704-4780-a306-89014ec18daf',
        rate: 4.5,
        maxRate: 5,
        currency: 'USD',
        products: [{
            productID: '0117b32a-5a6c-4d4c-b64c-7858e07dba78',
            name: 'PlasticHammer',
            price: 10,
            currency: 'USD',
        }],
    },
})

Share

123456
airbridge.events.send('airbridge.share', {
    semanticAttributes: {
        description: 'Share Promotion',
        sharedChannel: 'CopyLink',
    },
})

Schedule

1234567891011
airbridge.events.send('airbridge.schedule', {
    semanticAttributes: {
        scheduleID: '75712915-2cd9-4e42-a85e-8d42f356f4c6',
        datetime: '2024-01-01T00:00:00+00:00',
        place: 'ConferenceRoom',
        products: [{
            productID: 'abb3e65d-17bc-4b28-89e3-5e356c0ea697',
            name: 'ConferenceRoom',
        }],
    },
})

Spend Credits

123456789101112
airbridge.events.send('airbridge.spendCredits', {
    semanticAttributes: {
        transactionID: '22eb193d-be11-4fe4-95da-c91a196faf1c',
        currency: 'USD',
        products: [{
            productID: '0117b32a-5a6c-4d4c-b64c-7858e07dba78',
            name: 'PlasticHammer',
            price: 10,
            currency: 'USD',
        }],
    },
})

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

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

12345678
// ID
airbridge.setUserID('testID')
airbridge.clearUserID()

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

123456789101112
// Automatically hashed on client side using SHA256
// Can turn off hashing feature with special flag
airbridge.setUserEmail('testID@ab180.co')
airbridge.setUserPhone('821012341234')

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

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

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

123456789101112131415161718192021222324252627282930
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',
        },
    },
    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>',
    },
})

Web-to-Store setup

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

123456789101112131415161718192021
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',
    },
    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>',
    },
})

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.

12345678910111213141516171819202122
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',
    },
    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>',
    },
})

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.

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

123456789101112131415161718192021222324252627282930
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',
    },
    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>',
    },
})

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.

123456
<button id="<BUTTON_ID>">앱으로 보기</button>
<script>
    document.querySelector('#<BUTTON_ID>').addEventListener('click', () => {
        airbridge.openDeeplink({ ... })
    })
</script>
123456
<button id="<BUTTON_ID>">앱으로 보기</button>
<script>
    document.getElementById('<BUTTON_ID>').onclick = function () {
        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.

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

123456
<button id="<BUTTON_ID>">앱 다운로드하기</button>
<script>
    document.querySelector('#<BUTTON_ID>').addEventListener('click', () => {
        airbridge.openDeeplink({ ... })
    })
</script>
123456
<button id="<BUTTON_ID>">앱 다운로드하기</button>
<script>
    document.getElementById('<BUTTON_ID>').onclick = function () {
        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.

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

123456
<button id="<BUTTON_ID>">웹으로 이동하기</button>
<script>
    document.querySelector('#<BUTTON_ID>').addEventListener('click', () => {
        airbridge.openDeeplink({ ... })
    })
</script>
123456
<button id="<BUTTON_ID>">웹으로 이동하기</button>
<script>
    document.getElementById('<BUTTON_ID>').onclick = function () {
        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.

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.

1234567891011121314151617181920212223242526
<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
1234567891011121314151617
<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.

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

123456789
<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>
123456789
<button id="<BUTTON_ID>">웹으로 이동하기</button>
<script>
    document.getElementById('<BUTTON_ID>').onclick = function () {
        airbridge.openDeeplink('https://other.example.com', function (error, response) {
            // Open the link with new window or tab.
            window.open(response.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.

Note

Airbridge cannot provide guidance on storing the user consent data and implementing the prompts. For assistance, consult legal professionals.

1. Check the location of the users who launched the app. If their location is within the EEA, check whether the user consent data has been previously collected. If not, user consent data collection is not required.

123456
airbridge.init({
    app: 'YOUR_APP_NAME',
    webToken: 'YOUR_WEB_TOKEN',
    // ...
    autoStartTrackingEnabled: false,
})

2. If no user consent data has been collected previously, you may collect the data using a prompt or other means. The user consent data fields that need to be collected are adPersonalization, adUserData.

After initializing the Airbridge SDK, send the user consent data and the user location data (eea) to the Airbridge SDK using the airbridge.setDeviceAlias function.

123456
// Based on actual region
airbridge.setDeviceAlias('eea', '0' or '1')

// Based on actual user consent
airbridge.setDeviceAlias('adPersonalization', '0' or '1')
airbridge.setDeviceAlias('adUserData', '0' or '1')

Refer to the table below for the user consent data and the user location data that need to be sent to the Airbridge SDK. Note that the Airbridge field names listed in the table below must be used to successfully send data.

3. After the user consent data and the user location data are sent to the Airbridge SDK, call the startTracking function.

1
airbridge.startTracking()

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.

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

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.

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

Attention

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

1234567891011
airbridge.init({
    app: '<YOUR_APP_NAME>',
    webToken: '<YOUR_WEB_TOKEN>',
    // ...
    utmParsing: true,
    utmParameterValueReplaceMap: {
        utm_source: {
            'before_replace': 'after_replace',
        },
    },
})

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.

12345678910
airbridge.init({
    app: '<YOUR_APP_NAME>',
    webToken: '<YOUR_WEB_TOKEN>',
    // ...
    urlQueryMapping: {
        channel: 'utm_source',
        campaign: 'utm_campaign',
        sub_id_1: 'my_sub_id',
    },
})

Attention

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

123456789101112131415161718192021
const queryStringToJSON = (url = '') => {
    const { searchParams } = new URL(url)
    return Object.fromEntries(searchParams.entries())
}

const url = window.location.href
const params = queryStringToJSON(url)

// initialize
airbridge.init({
    app: '<YOUR_APP_NAME>',
    webToken: '<YOUR_WEB_TOKEN>',
    // ...
    defaultChannel: params['utm_source'],
    defaultParams: {
        campaign: params['utm_campaign'],
        medium: params['utm_medium'],
        content: params['utm_content'],
        term: params['utm_term'],
    },
})
12345678910111213141516171819202122232425262728293031323334
function queryStringToJSON(url) {
    url = url || ''
    var index = url.indexOf('?')
    if (index < 0) {
        index = url.length - 1
    }
    var pairs = url.slice(index + 1).split('&')
    var object = {}
    pairs.forEach(function (string) {
        if (string.length === 0) {
            return
        }
        var pair = string.split('=')
        object[pair[0]] = decodeURIComponent(pair[1] || '')
    })
    return object
}

var url = window.location.href
var params = queryStringToJSON(url)

// initialize
airbridge.init({
    app: '<YOUR_APP_NAME>',
    webToken: '<YOUR_WEB_TOKEN>',
    // ...
    defaultChannel: params['utm_source'],
    defaultParams: {
        campaign: params['utm_campaign'],
        medium: params['utm_medium'],
        content: params['utm_content'],
        term: params['utm_term'],
    },
})

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.

12345
airbridge.events.send('category')

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

airbridge.events.wait(3000, function () {
    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.

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

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

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

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

1234567
// 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.

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.

123456789101112131415
// Subdomain #1: a.example.com
airbridge.init({
    app: '<YOUR_APP_NAME>',
    webToken: '<YOUR_WEB_TOKEN>',
    // ...
    useStoragePerApp: true,
})

// Subdomain #2: b.example.com
airbridge.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.

12345678910111213
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
}

You can configure options using the following parameters.

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

1234
interface TrackingLink {
    shortURL: string
    qrcodeURL: string
}
12345678910111213141516
airbridge.createTrackingLink(
    'test_channel',
    {
        campaign: 'test_campaign',
        deeplink_url: '<YOUR_SCHEME>://...',
        fallback_ios: 'store',
        fallback_android: 'store',
        fallback_desktop: 'https://www.example.com/'
    },
    ({ shortURL, qrcodeURL }) => {
        // Handling created tracking-link
    },
    (error) => {
        // Handling error
    }
)

12345678910111213141516
airbridge.createTrackingLink(
    'test_channel',
    {
        campaign: 'test_campaign',
        deeplink_url: '<YOUR_SCHEME>://...',
        fallback_ios: 'https://www.example.com/',
        fallback_android: 'https://www.example.com/',
        fallback_desktop: 'https://www.example.com/'
    },
    ({ shortURL, qrcodeURL }) => {
        // Handling created tracking-link
    },
    (error) => {
        // Handling error
    }
)

123456789101112131415
airbridge.createTrackingLink(
    'test_channel',
    {
        campaign: 'test_campaign',
        fallback_ios: 'store',
        fallback_android: 'store',
        fallback_desktop: 'https://www.example.com/'
    },
    ({ shortURL, qrcodeURL }) => {
        // Handling created tracking-link
    },
    (error) => {
        // Handling error
    }
)

123456789101112131415
airbridge.createTrackingLink(
    'test_channel',
    {
        campaign: 'test_campaign',
        fallback_ios: 'https://www.example.com/',
        fallback_android: 'https://www.example.com/',
        fallback_desktop: 'https://www.example.com/'
    },
    ({ shortURL, qrcodeURL }) => {
        // Handling created tracking-link
    },
    (error) => {
        // Handling error
    }
)

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

123456
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

123456789
<script>
(function(a_,i_,r_,_b,_r,_i,_d,_g,_e){function q(b,a){function d(){var l=x(b,a);y(l)}if(0<_g){var e,f=new (null!=(e=a_.XDomainRequest)?e:a_.XMLHttpRequest);e=function(){};f.open("GET",a);f.timeout=_g;f.onload=d;f.onerror=e;f.onprogress=e;f.ontimeout=e;f.send()}else d()}function y(b){if("complete"===i_.readyState)i_.head.appendChild(b);else{var a=function(){a_.removeEventListener("load",a);i_.head.appendChild(b)};a_.addEventListener("load",a)}}function x(b,a){var d=i_.createElement(r_);d.async=!0;d.src=a;d.onerror=function(){return z(b)};return d}function z(b){b.queue.filter(function(a){return 0<=_d.indexOf(a[0])}).forEach(function(a){a=a[1];a=a[a.length-1];"function"===typeof a&&a("Failed to load Airbridge SDK.")})}function r(b){var a={queue:null!=b?b:[],get isSDKEnabled(){return!1}};_i.concat(_d).forEach(function(d){var e=d.split("."),f=e.pop();e.reduce(function(l,t){var u;return l[t]=null!=(u=l[t])?u:{}},a)[f]=function(){a.queue.push([d,arguments])}});return a}null!=a_.__AIRBRIDGE__||(a_.__AIRBRIDGE__={mocks:[]});"undefined"!==typeof i_.documentMode&&(_r=_r.replace(/^https:/,""));a_.createAirbridge=function(){var b=r(),a;null==(a=a_.__AIRBRIDGE__)||a.mocks.push(b);q(b,_r);return b};a_[_b]||(_e=r(_e),a_[_b]=_e,q(_e,_r))})(window,document,"script","airbridge","https://static.airbridge.io/sdk/latest/airbridge.min.js","init startTracking stopTracking openBanner setBanner setDownload setDownloads openDeeplink setDeeplinks sendWeb setUserAgent setMobileAppData setUserID clearUserID setUserEmail clearUserEmail setUserPhone clearUserPhone setUserAttribute removeUserAttribute clearUserAttributes setUserAlias removeUserAlias clearUserAlias clearUser setUserId setUserAttributes addUserAlias setDeviceAlias removeDeviceAlias clearDeviceAlias setDeviceIFV setDeviceIFA setDeviceGAID events.send events.signIn events.signUp events.signOut events.purchased events.addedToCart events.productDetailsViewEvent events.homeViewEvent events.productListViewEvent events.searchResultViewEvent".split(" "),["events.wait","fetchResource","createTouchpoint","createTrackingLink"],0);

const customInstance = createAirbridge()
customInstance.init({
    app: '<YOUR_APP_NAME>',
    webToken: '<YOUR_WEB_TOKEN>',
})
</script>

1234567
import { createAirbridge } from 'airbridge-web-sdk-loader'

const customInstance = createAirbridge()
customInstance.init({
    app: '<YOUR_APP_NAME>',
    webToken: '<YOUR_WEB_TOKEN>',
})

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

123456789101112131415161718
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',
    },
})