The Airbridge Web SDK not only tracks web to app conversion data, but also attribution data for the web application itself. This gives you a more extensive insight on your users' journey, especially if you are running applications on both web and mobile. Data collected from the Web SDK is then aggregated and shown on the Airbridge dashboard, where comprehensive analytics for both your web and app are provided. Raw data can also be exported in CSV format for your convenience.



SDK Setup


SDK Installation

Use one of the three following options to install the SDK.

Install Directly as a Function (Option 1)

Add the following code at the end of the head element.

<script>
(function(a_,i_,r_,_b,_r,_i,_d,_g,_e){if(!a_[_b]){var d={queue:[]};_r.concat(_i).forEach(function(a){var i_=a.split("."),a_=i_.pop();i_.reduce(function(a,i_){return a[i_]=a[i_]||{}},d)[a_]=function(){d.queue.push([a,arguments])}});a_[_b]=d;a_=i_.getElementsByTagName(r_)[0];i_=i_.createElement(r_);i_.onerror=function(){d.queue.filter(function(a){return 0<=_i.indexOf(a[0])}).forEach(function(a){a=a[1];a=a[a.length-1];"function"===typeof a&&a("error occur when load airbridge")})};i_.async=1;i_.src="//static.airbridge.io/sdk/latest/airbridge.min.js";a_.parentNode.insertBefore(i_,a_)}})(window,document,"script","airbridge","init fetchResource setBanner setDownload setDownloads setDeeplinks sendWeb setUserAgent setUserAlias addUserAlias setMobileAppData setUserId setUserEmail setUserPhone setUserAttributes clearUser 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"]);

airbridge.init({
    app: 'App Name',
    webToken: 'Web SDK Token'
});
</script>

πŸ“˜

Protected Attribution Window

It is recommended to configure protected attribution windows when measuring web to app contributions. Please refer to this guide for more information.

airbridge.init({
    app: 'App Name',
    webToken: 'Web SDK Token'
    useProtectedAttributionWindow: true
});

πŸ“˜

App Name and Web SDK Token can be found at the Airbridge dashboard β†’ Settings β†’ Tokens.

Install using an NPM module (Option 2)

  1. Install the Airbridge NPM module.
npm install airbridge-web-sdk-loader
  1. Import airbridge and call the airbridge.init function.
import airbridge from 'airbridge-web-sdk-loader'

airbridge.init({
    app: 'App Name',
    webToken: 'Web SDK Token',
})

Install Using Google Tag Manager (Option 3)

Please refer to Install SDK Using Google Tag Manager


Supported Browsers

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

ChromeFirefoxSafariInternet Explorer
βœ”οΈβœ”οΈβœ”οΈIE 9 and above

Testing the SDK

Go to the web page where the SDK is installed, and run airbridge at the developer tools console.

640640

Example output when the Airbridge SDK is installed.

If you get a proper output, go to "Airbridge dashboard β†’ Raw Data β†’ Web Real-time Log" and make sure that "open" events are being shown.



User Setup


User Identifier and Attributes Setup upon SDK Initialization

User information is automatically sent upon the initialization of the SDK. User information will be stored on the browser's local storage and all subsequent events on the website will be sent with the user's information until signOut is called.

airbridge.init({
    app: 'App Name',
    webToken: 'Web SDK Token',
    user: {
        externalUserID: 'personID',
        externalUserEmail: '[email protected]',
        externalUserPhone: '1(123)123-1234',
        attributes: {
            age_group: 30,
            gender: 'Female'
        },
        alias: {
            amplitude_device_id: '83587901-2726-4E29-ACEB-A90B0F7E75F6',
        },
    }
});
AttributeTypeDescription
user.externalUserIDStringUser ID
user.externalUserEmailStringUser Email
user.externalUserPhoneStringUser phone number
user.attributesObjectCustom user attributes (Custom key-value pair)
user.aliasObjectUser alias

User Identifier Setup

Use the following method to setup your own user identifiers as opposed to external identifiers. It will be stored on the browser's local storage and all subsequent events on the website will be sent with the user's information until signOut is called.

airbridge.setUserId('personID');
airbridge.setUserEmail('[email protected]');

You may also setup user aliases that will help identity matching with third party tools (e.g. Amplitude, Braze).

airbridge.setUserAlias({
  "amplitude_id": "AMPpersonID",
  "braze_ext_id": "BRZpersonID"  
})

airbridge.addUserAlias("amplitude_id", "AMPpersonID")
airbridge.addUserAlias("braze_ext_id", "BRZpersonID")

User Attributes Setup

Additional user attributes can be used for a more accurate Multi-Touch Attribution (MTA) analysis, additional internal data analysis, and linking third-party solutions.

airbridge.setUserAttributes({
    "age": 45,
    "gender": "Female",
    "name": "Person Doe"
    // ...
});

Testing

Make sure that your user information settings are being properly sent through the SDK.

  1. Configure user identifier information.
  2. Send an event using the SDK.
  3. Click the event at "Airbridge dashboard β†’ Raw Data β†’ Web Real-time Logs"
  4. Check if the user information is correctly sent under the user block.



Event Setup


When important user actions occur, in-app events can be sent to measure the performance of each channel.

All event parameters are optional. However, more information about the event will help provide more accurate statistics.


Custom Events

Name Field Type Detailed Parameter Field Name Type Description of Parameter
send category String - - Event Name (required)
info Object label String Event sub attribute 1
action String Event sub attribute 2
value Number Custom event value
semanticAttributes Object Semantic event attributes
customAttributes Object Custom event attributes
airbridge.events.send("category", {
    label: "label",
    action: "action",
    value: 10,
    semanticAttributes: {
        transactionID: "transaction_123",
    },
    customAttributes: {
        key: "value",
    }
});

Standard Events

View Home Screen

Name Field Type Description of Parameter
homeViewEvent - - -
airbridge.events.send('airbridge.ecommerce.home.viewed');

User Sign up

Name Field Type Description
signUp userID String User's ID
userEmail string User's Email
userPhone string User's Phone
attributes object User's Attributes
alias object User's Alias
airbridge.setUserId('personID');
airbridge.setUserEmail('[email protected]');
airbridge.setUserPhone('1(123)123-1234');
airbridge.setUserAlias('alias1', 'value');
airbridge.setUserAttributes('attr1', 'value');

airbridge.events.send('airbridge.user.signUp');

User Log In

Name Field Type Description
signIn userID String User ID
userEmail String User Email
userPhone String User Phone
attributes Object User Attributes
alias Object User Alias
// Change user information to input, and send signIn event.
airbridge.events.signIn({
    userID: 'personID',
    userEmail: '[email protected]',
    userPhone: '1(123)123-1234',
    attributes: {
        age: 50,
    },
    alias: {
        other_id: 'doeID',
    },
});

// Change user information to { userID: 'personID' }, and send signIn event.
airbridge.events.signIn({
    userID: 'personID',
});

// Change user information to {}, and send signIn event.
// (Existing user information is removed.)
airbridge.events.signIn();


airbridge.setuserId('personID');
airbridge.setuserEmail('[email protected]');
airbridge.setuserPhone('1(123)123-1234');
airbridge.setAlias('alias1', 'value');
airbridge.setAttributes('attr1', 'value');

airbridge.events.send('airbridge.user.signIn');

User Log Out

Name Field Type Description of Parameter
signOut - - -
airbridge.events.send('airbridge.user.signout');

airbridge.clearUser();

View Product List

Field Type Detailed Parameter Field Name Type Description of Parameter
productListID string - - product list ID
products Array<Product> - - product array
productID string product ID
name string product name
price number product price
currency string product currency
quantity number product quantity
position number product position
airbridge.events.send('airbridge.ecommerce.productList.viewed', {
    semanticAttributes: {
        productListID: 'food',
        products: [
            {
                productID: 'coke_zero',
                name: 'Coke Zero',
                price: 1.99,
                currency: 'USD',
                position: 1
            },
            {
                productID: 'burger_cheese_double',
                name: 'Double Cheeseburger',
                price: 3.99,
                currency: 'USD',
                position: 2
            }
        ]
    }
});

View Product Details

Name Type Field Type Description of Parameter
products Array<Object> - - Product object array
productID string product ID
name string product name
price number product price
currency string product currency
quantity number product quantity
position number product position
airbridge.events.send('airbridge.ecommerce.product.viewed', {
    semanticAttributes: {
        products: [{
            productID: 'coke_zero',
            name: 'Coke Zero',
            price: 1.99,
            currency: 'USD',
            position: 1
        }]
    }
});

View Search Results

Field Type Detailed Parameter Field Name Type Description of Parameter
query string - - Search Query
products Array<Product> - - Product Array
productID string Product ID
name string Product Name
price number Product Price
currency string Product Currency
quantity number product quantity
position number Product Position
airbridge.events.send('airbridge.ecommerce.searchResults.viewed', {
    semanticAttributes: {
        products: [
            {
                productID: 'coke_zero',
                name: 'Coke Zero',
                price: 1.99,
                currency: 'USD',
                position: 1
            },
            {
                productID: 'burger_cheese_double',
                name: 'Double Cheeseburger',
                price: 3.99,
                currency: 'USD',
                position: 2
            }
        ],
        query: 'Search Query'
    }
});

Add To Cart

Field Type Detailed Parameter Field Name Type Description of Parameter
cartID string - - Product Cart ID
totalValue number - - Product Total Value
currency string - - Product Currency
products Array<Product> - - Product Array
productID string Product ID
name string Product Name
price number Product Price
currency string Product Currency
quantity number Product Quantity
position number Product Position
airbridge.events.send('airbridge.ecommerce.product.addedToCart', {
    semanticAttributes: {
        products: [
            {
                productID: 'coke_zero',
                name: 'Coke Zero',
                price: 1.99,
                currency: 'USD',
                quantity: 3,
                position: 1
            },
            {
                productID: 'burger_cheese_double',
                name: 'Double Cheeseburger',
                price: 3.99,
                currency: 'USD',
                quantity: 2,
                position: 2
            }
        ],
        cartID: '73926365',
        totalValue: 13.95,
        currency: 'USD'
    }
});

Order Complete

Field Type Detailed Parameter Field Name Type Description of Parameter
inAppPurchased boolean - - Product In-App Purchased
totalValue number - - Product Total Value
currency string - - Product Currency
transactionID string - - Transaction ID
products Array<Product> - - Product Array
productID string Product ID
name string Product Name
price number P
currency string Product Currency
quantity number Product Quantity
position number Product Position
airbridge.events.send('airbridge.ecommerce.order.completed', {
    semanticAttributes: {
        products: [
            {
                productID: 'coke_zero',
                name: 'Coke Zero',
                price: 1.99,
                currency: 'USD',
                quantity: 3,
                position: 1
            },
            {
                productID: 'burger_cheese_double',
                name: 'Double Cheeseburger',
                price: 3.99,
                currency: 'USD',
                quantity: 2,
                position: 2
            }
        ],
        inAppPurchased: true,
        totalValue: 13.95,
        currency: 'USD',
        transactionID: '16874326'
    }
});

Verify Event Transmission

Make sure that the events are being properly sent through the SDK.

  1. Send an event with the SDK.
  2. Check if the event shows up at "Airbridge dashboard β†’ Raw Data β†’ Web Real-time Logs".



Web to App Setup


The Airbridge Web SDK enables you to provide a seamless web to app experience for your users. The below method saves developers from having to code each button separately and also makes sure that your buttons work with all major browsers.


Add Download Button

Use the id value of your buttons to add a download function and track it's performance.

// html
<button id="app_download">Go to app</button>

// javascript
airbridge.setDownload({
    buttonID: "app_download",
    // or ["app_download_1", "app_download_2", ...]
    defaultParams: {
        campaign: 'example_campaign',
        medium: 'example_medium',
        term: 'example_term',
        content: 'example_content',
    }
});

Required

  • buttonID: Values of the id attribute of a button. Can be an array.

Optional

  • defaultParams: Campaign parameters

If set, defaultParams will be sent when the button is clicked.

Caution : Since the SDK should be responsible for sending the user to the app market, do not use <a> tags or the onclick function.


Add DeepLink Button

Use the id value of your buttons to embed deep links and track it's performance.
setDeeplinks allows you to customize actions for each button. Not only can you setup redirections to your deep links for each platform (OS) separately, you can override fallbacks and campaign parameters too. This allows web attributions to be properly tracked, and saves you from creating separate deep links for all the buttons on your website.

airbridge.setDeeplinks({
    buttonID: "deeplinking-button-1",
    // or ["deeplink-button-1", "deeplink-button-2", ...]
    deeplinks: {
        ios: "ablog://main",
        android: "ablog://main",
        desktop: "https://www.airbridge.io/blog"
    },
    fallbacks: {
        ios: "itunes-appstore",
        // itunes-appstore(default), google-play, url
        android: "google-play"
        // google-play(default), itunes-appstore, url
    },
    defaultParams: {
        campaign: 'example_campaign',
        medium: 'example_medium',
        term: 'example_term',
        content: 'example_content'
    },
    desktopPopUp: true
});

Required

  • deeplinks.ios: The deep link to run when the button is clicked in an iOS environment. (Only deep links using schemes are allowed)
  • deeplinks.android: The deep link to run when the button is clicked in an Android environment. (Only deep links using schemes are allowed)
  • deeplinks.desktop: The deep link to run when the button is clicked in a desktop environment.
  • fallbacks.ios: The destination for when the deep link fails in iOS.
  • fallbacks.android: The destination for when the deep link fails in Android.
    • itunes-appstore: App's Apple AppStore page
    • google-play : App's Android PlayStore page
    • url : A http/https scheme URL
  • buttonID: Values of the id attribute of a button. Can be an array.

Optional

  • defaultParams : Campaign parameters
  • desktopPopUp : If set to true, deep links will run in a new window when in a desktop environment.

Caution : Since the SDK should be responsible for sending the user to the app market, do not use <a> tags or the onclick function.


Relay Page Setup

If redirect: true is set, the deep link will run automatically for all incoming requests that try to access the webpage.

airbridge.setDeeplinks({
    buttonID: "deeplinking-button-1",
    deeplinks: {
        ios: "ablog://main",
        android: "ablog://main",
        desktop: "https://www.airbridge.io/blog"
    },
    fallbacks: {
        ios: "itunes-appstore",
          // itunes-appstore(default), google-play, url
        android: "google-play"
        // google-play(default), itunes-appstore, url
    },
    redirect: true
});

Web to App Banner

The web to app banner is a banner that encourages web users to install apps.

380380
airbridge.setBanner({
    title: 'AirStyle',
    description: 'Find your perfect style!!',
    keyColor: '#00a0c6',
    position: 1
});

You can change the title, description, button color and other properties of the banner.



Advanced Settings


Campaign Parameter Setup

If your ad's landing page is a website, you can use several parameters to add additional information to the URL. The parameters can be used to track the user journey to your website.

Parameter analysis can be either automatic or manual.

utmParsing (Automatic)

When the airbridge.init method is called with the utmParsing: true option, UTM values are automatically stored as Airbridge campaign parameters and can be seen in the Airbridge Actuals report.

URL ParameterAirbridge Campaign Parameter
utm_sourceChannel (channel)
utm_campaignCampaign (campaign)
utm_mediumSub Publisher (sub_id)
utm_termTerm (term)
utm_contentContent (content)

πŸ“˜

Other UTM parameters will not be parsed if utm_source is missing.

airbridge.init({
    app: 'App Name',
    webToken: 'Web SDK Token',
    utmParsing: true
});

The URL is the window.location.href value.

urlQueryMapping (Automatic)

When the init method is called with the utmParsing: true option, UTM values are automatically stored as Airbridge campaign parameters and can be seen in the Airbridge Actuals report.
You can use urlQueryMapping to automatically store parameters other than the UTM parameters. Insert key-value pairs for urlQueryMapping when the airbridge.init method is called. Below are the keys you can use with Airbridge.

Parameter NameDescription
channelChannel
campaignCampaign
ad_groupAdvertising group
ad_creativeAdvertising creative
contentContent
termKeyword
sub_idSub publisher
sub_id_1Sub sub publisher 1
sub_id_2Sub sub publisher 2
sub_id_3Sub sub publisher 3
campaign_idCampaign ID
ad_group_idAdvertising group ID
ad_creative_idAdvertising creative ID
term_idKeyword ID

If a custom parameter such as internal_code is used with utm_source and utm_campaign, the URL will be structured as below.

https://example.com/?utm_source=google&utm_campaign=jan_ua_campaign&internal_code=ABC

Below is an example of how you can map each parameter so that it shows on the Airbridge dashboard.

airbridge.init({
    app: 'App Name',
    webToken: 'Web SDK Token',
    urlQueryMapping: {
      channel: 'utm_source',
      campaign: 'utm_campaign', 
      sub_id_1: 'internal_code'
    }
});

If a conversion happens through the above URL, the data for internal_code will be available at "Airbridge dashboard β†’ Actuals Report β†’ Configuration β†’ GroupBy β†’ Sub Sub Publisher 1".

Manual functions

Below is an example of how you can manually parse parameters.

Extract information from the params object and register the information when calling the init function.

// νŒŒλΌλ―Έν„° νŒŒμ‹± ν•¨μˆ˜
function queryStringToJSON(url) {
    if (url.search.slice !== undefined) {
        var pairs = url.search.slice(1).split('&');
    } else {
        var pairs = url.split('?')[1].split('&');
    }

    var result = {};
    pairs.forEach(function(pair) {
        pair = pair.split('=');
        result[pair[0]] = decodeURIComponent(pair[1] || '');
    });

    return JSON.parse(JSON.stringify(result));
}

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

// initialize
airbridge.init({
    app: 'App Name',
    webToken: 'Web SDK Token',
    defaultChannel: params['utm_source'],
    defaultParams: {
        campaign: params['utm_campaign'],
        medium: params['utm_medium'],
        content: params['utm_content'],
        term: params['utm_term']
    }
});
NameDescription
defaultChannelName of the advertiser to be recorded in all events on the web page
defaultParams.campaignName of the campaign to be recorded in all events occurring on the web page
defaultParams.mediumAdvertising media to be recorded in all events occurring on the web page
defaultParams.contentThe content of the ad to be recorded in all events occurring on the web page
defaultParams.termThe ad query that will be recorded for all events on the web page.

Clear User Information

Use the clearUser method to delete User ID, email, phone, alias and attributes of a user.

airbridge.clearUser()

Encrypt user information

Hash (SHA256) user.externalUserEmail and user.externalUserPhone at the client level. This option will not affect user.externalUserID and it will not be hashed.

airbridge.init({
    app: 'App Name',
    appToken: 'Web SDK Token',
    userHash: true, // default is "false"
    // ...
});

Delay Event Transmission

Data could be lost if a redirection occurs before the event is completely sent (e.g. sending an event from a relay page). Use events.wait to make sure the events are sent before being redirected.

ParameterTypeDescription
timeoutNumberMaximum wait time (milliseconds)
callback(error: string) => voidCallback for when the event is sent
airbridge.init({
    app: 'App Name',
    webToken: 'Web SDK Token'
});

airbridge.events.send('category');

airbridge.events.wait(3000, function (error) {
    location.href = 'url';
});

Attribution Window Setup

Use cookieWindow to adjust your attribution window.

// Set attribution window to 1 day
airbridge.init({
    app: 'App Name',
    webToken: 'Web SDK Token',
    cookieWindow: 1
});

// Set attribution window to 720 minutes (12 hours)
airbridge.init({
    app: 'App Name',
    webToken: 'Web SDK Token',
    cookieWindowInMinutes: 720
});

πŸ“˜

If both cookieWindow and cookieWindowInMinutes are set, cookieWindowInMinutes is applied.


Cookie Share Option

User tracking is done through browser cookies, which are shared between subdomains.
Set shareCookieSubdomain as false to stop sharing cookies between subdomains.

// initialize 
airbridge.init({ 
    app: 'App Name',
    webToken: 'Web SDK Token',
    shareCookieSubdomain: false
});

Default value of shareCookieSubdomain is true.

  • If one service uses several subdomains, true is recommended.
  • If several services use several subdomains, false is recommended.

Example

Campaign A Tracking Link β†’ https://airbridge.io β†’ https://blog.airbridge.io,

  • shareCookieSubdomain: true
    • Event on https://airbridge.io β†’ Attributed to Campaign A
    • Event on https://blog.airbridge.io β†’ Attributed to Campaign A
  • shareCookieSubdomain: false
    • Event on https://airbridge.io β†’ Attributed to Campaign A
    • Event on http://blog.airbridge.io β†’ Attributed to Default Campaign

Personal Information Protection

If autoStartTrackingEnabled is set to false when initializing the SDK, events will not be sent until airbridge.startTracking is called.

airbridge.init({
    app: 'App Name',
    webToken: 'Web SDK Token',
    autoStartTrackingEnabled: false,
});

airbridge.startTracking()

Default value for autoStartTrackingEnabled is true.


Protected Attribution Window

If the app is already installed when clicking a button with a deep link, a "Deep Link Open (App)" event occurs. When this happens, the button is seen as a re-engagement touchpoint and the event is contributed to "Owned Channel Type Touchpoint (airbridge.websdk)".
Set useProtectedAttributionWindow as true to credit the contribution to the media channel.

SituationDefault Contribution ChannelContribution Channel when Protected Attribution Window is UsedType
1. Click media channelnaver.searchadnaver.searchadTouchpoint (Intergrated Channel Type)
2. Open webpagenaver.searchadnaver.searchadConversion (Web)
3. Click "See with App" button (using an Airbridge deep link)airbridge.websdkairbridge.websdkTouchpoint (Owned Channel Type)
4. Open App with deep linkairbridge.websdknaver.searchadConversion (App)
airbridge.init({
    app: 'App Name',
    webToken: 'Web SDK Token',
    // ...
    useProtectedAttributionWindow: true
      protectedAttributionWindowInMinutes: 60
});

The default value for protectedAttributionWindowInMinutes is 30. This means that once a web page is opened after clicking on the media channel, the "deep link open (App)" event will be credited to the media channel only if it occurs within 30 minutes of opening the web page. protectedAttributionWindowInMinutes can be set to a maximum of 4320 (3 days).


Track Journey to Another Website

Use the sendWeb method when the user is moving to another website. If the user moves to a website that has the Airbridge Web SDK installed, Airbridge can connect the attributions for analysis.

πŸ“˜

useProtectedAttributionWindow must be set as true when initializing the Airbridge SDK to connect the attributions. Please refer to Protected Attribution Window.

// Open in same window
airbridge.sendWeb("https://www.airbridge.io/blog")

// Open in new window
airbridge.sendWeb("https://www.airbridge.io/blog", function(err, res) {
  window.open(res.targetUrl)
})

Using Google Tag Manager

The Airbridge SDK can be installed using Google Tag Manager.

SDK Installation

Follow the below steps to install the Airbridge SDK using Google Tag Manager.

  1. Click on "New Tag" in "Workspace Overview", or select "Tag β†’ New" in the container.
  2. Select "Custom HTML" at "Tag Configuration β†’ Custom Settings".
  3. Insert the Airbridge SDK code code in the "HTML" section as shown in the picture below.
  4. Go to "Tag Configuration β†’ Advanced Settings β†’ Tag firing priority" and enter a number greater than 0 (e.g. 9999).
  5. Select "Once per page" at "Tag Configuration β†’ Advanced Settings β†’ Tag firing Options"
  6. Set "Trigger" to "Pageview - DOM Ready".
  7. Complete the tag creation and press the submit button.
  8. Check the Airbridge dashboard under real-time logs to verify that the SDK logs are logged properly.
14101410

Event Tracking

Follow these steps to track events using Google Tag Manager.

  1. Click on "New Tag" in "Workspace Overview", or select "Tag β†’ New" in the container.
  2. Select "Custom HTML" at "Tag Configuration β†’ Custom Settings".
  3. Insert the code for the events you want to track in the "HTML" section as shown in the picture below.
  4. Depending on the event, select "Unlimited", "Once per event" or "Once per page" at "Advancded Settings > Tag firing options".
  5. Set the appropriate trigger for the event.
  6. Complete the tag creation and press the submit button.
  7. Check the Airbridge dashboard under real-time logs to verify that the SDK logs are logged properly.
902902