Install SDK
Install the Airbridge Web SDK using one of the methods below.Load from the browser directly
Load from the browser directly
<head> section.Install using the package manager
Install using the package manager
airbridge-web-sdk-loader.airbridge-web-sdk-loader package, you can refer to the code below.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 theairbridge.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.
SDK initialization options
SDK initialization options
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.true is printed after running the code above, the SDK has been installed and initialized successfully.
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.false is being printed due to network delay, run the code below in the developer tools to check the value after 5 seconds.
Opt-in setup
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.
- Prevent automatic event tracking after initialization through the
autoStartTrackingEnabled.
- Collect user responses to the collection and use of personal information. If the user agrees to the collection and use of personal information, start tracking events.
Opt-out setup
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.
- Enable automatic event tracking after initialization through the
autoStartTrackingEnabled. Since the default value of theautoStartTrackingEnabledoption is true, events are tracked automatically event if this setting is omitted.
- Collect user responses to the collection and use of personal information. If the user refuses the collection and use of personal information, stop tracking events.
Web Event
The Airbridge Web SDK collects user actions from the app as per settings and sends them as in-app events.Send web events
Use theairbridge.events.send function to send events.
Refer to the example below.
Event Category
Event Category
Attributes
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.
Additional web event settings
Device identifier setup
Device identifier setup
Example codes
Airbridge collects in-app events that are classified as Standard Events and Custom Events. Standard Events. are events predefined by Airbridge. Refer to the example codes below.Sign-up, Sign-in, Sign-out, Home Screen, Product Catalog
Sign-up, Sign-in, Sign-out, Home Screen, Product Catalog
Search Results, Product View, Add Payment Info, Add to Wishlist, Add to Cart
Search Results, Product View, Add Payment Info, Add to Wishlist, Add to Cart
Initiate Checkout, Order Complete, Order Cancel, Start Trial, Subscribe, Unsubscribe
Initiate Checkout, Order Complete, Order Cancel, Start Trial, Subscribe, Unsubscribe
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.Ad Impression, Ad Click, Complete Tutorial, Achieve Level, Unlock Achievement
Ad Impression, Ad Click, Complete Tutorial, Achieve Level, Unlock Achievement
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.Set up user properties
true.
The user ID is not affected by the hash option, so if hashing is required, you must hash the user ID yourself before assigning its value.
Clear user data
Use theclearUser function to clear user data.
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 theopenBanner 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 thetype of the destination option is set to deeplink, clicking the banner button will open the app.
Web-to-Store setup
If thetype of the destination option is set to download, clicking the banner button will open the app store.
Web-to-Web setup
If thetype of the destination option is set to web, clicking the banner button will navigate the user to a specified website.
Custom style setup
You can customize the banner’s appearance by adding astyles 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-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 theopenDeeplink function to open the app via a deep link.
deeplinks.android and deeplinks.ios.<YOUR_SCHEME>://...
intent://...market://...https://www.example.com
<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 thedeeplinks option in the openDeeplink function and set the fallbacks option to store, the app store will open regardless of whether the app is installed.
<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 thedeeplinks 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.
<BUTTON_ID> in the example with the actual ID of the button that should trigger the deep link when the user clicks it.Creating a button to open the app via deep link
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.setDeeplinks function to assign deep link functionality to a button.
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.Create a button to open the store through a deep link
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.setDownloads function to configure the store redirection functionality to a button.
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
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.sendWeb function to send users to a website on a different domain. In this case, attribution data can be passed across the websites.
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.Collecting user consent data using the airbridge.setDeviceAlias function
Collecting user consent data using the airbridge.setDeviceAlias function
- 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.
- 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.
eea) to the Airbridge SDK using the airbridge.setDeviceAlias function.- After the user consent data and the user location data are sent to the Airbridge SDK, call the
startTrackingfunction.
Pass user data during initialization
You can pass user data during initialization so that all subsequent events include the user data. The user data you set is stored in the browser’s local storage and will be included in all events until it is cleared.Set up campaign parameters
When users land on your website through an ad, you can append parameters to the URL to enable web traffic attribution based on that information.Automatic UTM parameter setting
Automatic UTM parameter setting
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.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.Replace the UTM parameter value
Replace the UTM parameter value
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.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.Set non-UTM parameters as campaign parameters
Set non-UTM parameters as campaign parameters
urlQueryMapping option, you can include non-UTM parameters as campaign parameters and send them with events.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
sub_id_1 as my_sub_id in the Airbridge dashboard, along with utm_source and utm_parameter.channel in the urlQueryMapping option. If not, all other options are also ignored.Manually parse parameters
Manually parse parameters
init function.Set delay time to ensure event transmission
You can use theevents.wait function to ensure that all event transmissions are completed before the user navigates away.
If a page is navigated away before the events are fully transmitted, there is a risk of event data loss. For example, when transmitting event data on an intermediate page that quickly redirects, use events.wait and minimize the risk of data loss.
Edit the attribution window
You can set the attribution window in days using thecookieWindow option.
The default setting is 3 days.
cookieWindowInMinutes option. If both cookieWindow option and cookieWindowInMinutes option are configured, the cookieWindowInMinutes option takes precedence.
Set the attribution window for web-to-app attribution
You can configure the Protected Attribution Window (PAW) using theuseProtectedAttributionWindow option.
The default setting is true.
- When
useProtectedAttributionWindowis set totrue, PAW is applied. For more details, refer to the User Guide. - When
useProtectedAttributionWindowis set tofalse, PAW is not applied. For more details, refer to the User Guide.
protectedAttributionWindowInMinutes option.
The default value is 30 minutes, and it can be set up to a maximum of 3 days (4320 minutes).
This option is only enabled when useProtectedAttributionWindow is set to true.
Share attribution data across subdomains
By default, the Airbridge Web SDK stores attribution data in cookies and uses the root domain’s cookie storage. This allows attribution data to be shared across subdomains. If you’re using multiple subdomains, you can configure whether to share cookies between them using theshareCookieSubdomain option.
When shareCookieSubdomain is set to false, data will not be shared between subdomains.
The default setting is true.
- Set to
trueif you are operating a single service across multiple subdomains. - Set to
falseif you are operating different services on each subdomain.
Example scenario
Example scenario
- A user clicks a tracking link for Campaign A and lands on
https://www.airbridge.io. - The user then clicks a link on the site and is redirected to
https://blog.airbridge.io.
shareCookieSubdomain setting:truehttps://www.airbridge.io→ Attributed to Campaign Ahttps://blog.airbridge.io→ Attributed to Campaign A
falsehttps://www.airbridge.io→ Attributed to Campaign Ahttps://blog.airbridge.io→ Unattributed
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 theuseStoragePerApp 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.
useStoragePerApp option, the first event triggered in each browser immediately after the change may be unattributed.Create tracking links from the web
You can create a tracking link using thecreateTrackingLink 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.
Configure tracking link options
Configure tracking link options
options using the following parameters.createTrackingLink function are passed via the onSuccess callback.
Create tracking links that launch the app or redirect users to the app store
Create tracking links that launch the app or redirect users to the app store
Create tracking links that launch the app or redirect users to a webpage
Create tracking links that launch the app or redirect users to a webpage
Create tracking links that redirects users to the app store only
Create tracking links that redirects users to the app store only
Create tracking links that redirects users to a webpage only
Create tracking links that redirects users to a webpage only
Collect Moloco cookie ID
WhencollectMolocoCookieID is set to true, the SDK automatically collects the cookie ID from events driven by Moloco web campaigns, enabling campaign optimization.
Using multiple apps
By defaults, the Airbridge Web SDK is accessed via a globalairbridge 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
Creation via browser script
Creation via browser script
Creation via browser script
Creation via browser script
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.