airbridge-web-sdk
    Preparing search index...

    Interface Airbridge

    interface Airbridge {
        init(options: InitializeOptions): void;
        init(
            options: InitializeOptions,
            callback: (error?: unknown, airbridge?: Airbridge) => void,
        ): void;
        startTracking(): void;
        stopTracking(): void;
        fetchResource(callback: (resource: FetchResourceResponse) => void): void;
        setUserID(userID: string): void;
        clearUserID(): void;
        setUserEmail(userEmail: string): void;
        clearUserEmail(): void;
        setUserPhone(userPhone: string): void;
        clearUserPhone(): void;
        setUserAttribute(key: string, value: unknown): void;
        removeUserAttribute(key: string): void;
        clearUserAttributes(): void;
        setUserAlias(key: string, value: string): void;
        removeUserAlias(key: string): void;
        clearUserAlias(): void;
        clearUser(): void;
        setDeviceAlias(key: string, value: string): void;
        removeDeviceAlias(key: string): void;
        clearDeviceAlias(): void;
        createTouchpoint(
            options: CreateTouchpointOptions,
            callback: (error?: unknown, touchpoint?: CreateTouchpointResponse) => void,
        ): void;
        sendWeb(url: string): void;
        sendWeb(
            url: string,
            callback: (error?: unknown, response?: SendWebResponse) => void,
        ): void;
        setDownloads(options: SetDownloadsOptions): void;
        setDeeplinks(options: SetDeeplinksOptions): void;
        openDeeplink(options: OpenDeeplinkOptions): void;
        setBanner(options: SetBannerOptions): void;
        openBanner(options: OpenBannerOptions): void;
        createTrackingLink(
            channel: string,
            options: CreateTrackingLinkOptions,
            onSuccess: (trackingLink: CreateTrackingLinkResponse) => void,
        ): void;
        createTrackingLink(
            channel: string,
            options: CreateTrackingLinkOptions,
            onSuccess: (trackingLink: CreateTrackingLinkResponse) => void,
            onError: (error: Error) => void,
        ): void;
        events: WebEvent;
    }
    Index

    Properties

    events: WebEvent

    Methods

    • Initializes the Airbridge Web SDK with the given options.

      Parameters

      • options: InitializeOptions

        The options to initialize the SDK.

        • app: string

          The name of your application.

        • webToken: string

          The web token for your application.

        • OptionalautoStartTrackingEnabled?: boolean

          Whether to automatically start event tracking when the SDK is initialized.
          If set to true, the SDK will automatically start event tracking when the SDK is initialized.
          If set to false, you need to call the airbridge.startTracking method manually to start event tracking.

          true
          
        • OptionalcollectMolocoCookieID?: boolean

          Whether to collect the Moloco cookie ID.
          If set to true, the SDK will collect the Moloco cookie ID.
          If set to false, the SDK will not collect the Moloco cookie ID.

          false
          
        • OptionalcookieWindow?: number

          The window time in days for the cookie expiration.

          3
          
        • OptionalcookieWindowInMinutes?: number

          The window time in minutes for the cookie expiration.
          If set, this will override the InitializeOptions.cookieWindow option.

        • OptionaldefaultChannel?: string

          The default channel name for the attribution.

        • OptionaldefaultParams?: AttributionParameters

          The default attribution parameters.

        • OptionalforceFirstPartyCookieID?: boolean

          Whether to use the first-party cookie ID instead of the third-party cookie ID for the attribution.
          If set to true, the SDK will use the first-party cookie ID for the attribution.
          If set to false, the SDK will use the third-party cookie ID for the attribution.

          false
          
        • Optional ExperimentaloverwriteInstance?: boolean

          Whether to overwrite the existing instance of the SDK.
          If set to true, the SDK will re-initialize the global instance by replacing the existing instance with the new instance.

          false
          
        • OptionalprotectedAttributionWindowInMinutes?: number

          The window time in minutes for the protected attribution window.
          This option will be ignored if InitializeOptions.useProtectedAttributionWindow is false.

          30
          
        • OptionalsessionTimeout?: number

          The session timeout in milliseconds.

          1800000 (30 minutes)
          
        • OptionalshareCookieSubdomain?: boolean

          Whether to save the cookie in the subdomain.
          If set to true, the SDK will save the cookie in the subdomain.
          If set to false, the SDK will save the cookie in the root domain if localStorage is not available.

          true
          
        • OptionalurlQueryMapping?: URLQueryMapping

          Sets the mapping for the URL query parameters.
          This option will be ignored if InitializeOptions.utmParsing is false.

          airbridge.init({
          urlQueryMapping: {
          channel: 'utm_source',
          campaign: 'utm_campaign',
          },
          })
        • OptionaluseProtectedAttributionWindow?: boolean

          Whether to use the protected attribution window.
          If set to true, the SDK will parse the UTM parameters from the URL.

          true
          
        • Optionaluser?: User

          Sets the user object for the attribution.

        • OptionaluserHash?: boolean

          Whether to hash the user email and phone number.
          If set to true, the SDK will hash the user email and phone number when sending the event.

          true
          
        • OptionaluseStoragePerApp?: boolean

          No longer has any effect. This option is always treated as true.
          Whether to split the storage per application name.
          If set to true, the SDK will split the storage per application name.

          true
          
        • OptionalutmParameterValueReplaceMap?: UTMParameterValueReplaceMap

          Sets the mapping for the UTM parameters.

          airbridge.init({
          utmParameterValueReplaceMap: {
          utm_source: {
          'test.1': 'test',
          'test.2': 'test',
          },
          },
          })
        • OptionalutmParsing?: boolean

          Whether to parse the UTM parameters from the URL.
          If set to true, the SDK will parse the UTM parameters from the URL.

          false
          

      Returns void

      airbridge.init({
      app: 'YOUR_APPLICATION_NAME',
      webToken: 'YOUR_WEB_TOKEN',
      })
    • Initializes the Airbridge Web SDK with the given options and calls the provided callback function.

      Parameters

      • options: InitializeOptions

        The options to initialize the SDK.

        • app: string

          The name of your application.

        • webToken: string

          The web token for your application.

        • OptionalautoStartTrackingEnabled?: boolean

          Whether to automatically start event tracking when the SDK is initialized.
          If set to true, the SDK will automatically start event tracking when the SDK is initialized.
          If set to false, you need to call the airbridge.startTracking method manually to start event tracking.

          true
          
        • OptionalcollectMolocoCookieID?: boolean

          Whether to collect the Moloco cookie ID.
          If set to true, the SDK will collect the Moloco cookie ID.
          If set to false, the SDK will not collect the Moloco cookie ID.

          false
          
        • OptionalcookieWindow?: number

          The window time in days for the cookie expiration.

          3
          
        • OptionalcookieWindowInMinutes?: number

          The window time in minutes for the cookie expiration.
          If set, this will override the InitializeOptions.cookieWindow option.

        • OptionaldefaultChannel?: string

          The default channel name for the attribution.

        • OptionaldefaultParams?: AttributionParameters

          The default attribution parameters.

        • OptionalforceFirstPartyCookieID?: boolean

          Whether to use the first-party cookie ID instead of the third-party cookie ID for the attribution.
          If set to true, the SDK will use the first-party cookie ID for the attribution.
          If set to false, the SDK will use the third-party cookie ID for the attribution.

          false
          
        • Optional ExperimentaloverwriteInstance?: boolean

          Whether to overwrite the existing instance of the SDK.
          If set to true, the SDK will re-initialize the global instance by replacing the existing instance with the new instance.

          false
          
        • OptionalprotectedAttributionWindowInMinutes?: number

          The window time in minutes for the protected attribution window.
          This option will be ignored if InitializeOptions.useProtectedAttributionWindow is false.

          30
          
        • OptionalsessionTimeout?: number

          The session timeout in milliseconds.

          1800000 (30 minutes)
          
        • OptionalshareCookieSubdomain?: boolean

          Whether to save the cookie in the subdomain.
          If set to true, the SDK will save the cookie in the subdomain.
          If set to false, the SDK will save the cookie in the root domain if localStorage is not available.

          true
          
        • OptionalurlQueryMapping?: URLQueryMapping

          Sets the mapping for the URL query parameters.
          This option will be ignored if InitializeOptions.utmParsing is false.

          airbridge.init({
          urlQueryMapping: {
          channel: 'utm_source',
          campaign: 'utm_campaign',
          },
          })
        • OptionaluseProtectedAttributionWindow?: boolean

          Whether to use the protected attribution window.
          If set to true, the SDK will parse the UTM parameters from the URL.

          true
          
        • Optionaluser?: User

          Sets the user object for the attribution.

        • OptionaluserHash?: boolean

          Whether to hash the user email and phone number.
          If set to true, the SDK will hash the user email and phone number when sending the event.

          true
          
        • OptionaluseStoragePerApp?: boolean

          No longer has any effect. This option is always treated as true.
          Whether to split the storage per application name.
          If set to true, the SDK will split the storage per application name.

          true
          
        • OptionalutmParameterValueReplaceMap?: UTMParameterValueReplaceMap

          Sets the mapping for the UTM parameters.

          airbridge.init({
          utmParameterValueReplaceMap: {
          utm_source: {
          'test.1': 'test',
          'test.2': 'test',
          },
          },
          })
        • OptionalutmParsing?: boolean

          Whether to parse the UTM parameters from the URL.
          If set to true, the SDK will parse the UTM parameters from the URL.

          false
          
      • callback: (error?: unknown, airbridge?: Airbridge) => void

        Callback function to be called after initialization.

      Returns void

      airbridge.init({
      app: 'YOUR_APPLICATION_NAME',
      webToken: 'YOUR_WEB_TOKEN',
      }, (error) => {
      if (error) {
      // Handle the error
      console.error('Error initializing Airbridge:', error)
      return
      }
      // Airbridge is initialized successfully
      })
    • Starts the event tracking.

      Returns void

      airbridge.startTracking()
      
    • Stops the event tracking.

      Returns void

      airbridge.stopTracking()
      
    • Fetches the resource and calls the provided callback function with the response.

      Parameters

      • callback: (resource: FetchResourceResponse) => void

        Callback function to be called with the fetched resource.

      Returns void

      airbridge.fetchResource((resource) => {
      // Handle the fetched resource
      console.log('Fetched resource:', resource)
      })
    • Sets the user ID who is logged in to the current website, in order to integrate user identity.

      Parameters

      • userID: string

        The user ID to set.

      Returns void

      airbridge.setUserID('user-id')
      
    • Clears the user ID.

      Returns void

      airbridge.clearUserID()
      
    • Sets the user email who is logged in to the current website, in order to integrate user identity.

      Parameters

      • userEmail: string

        The user email to set.

      Returns void

      airbridge.setUserEmail('user-email')
      
    • Clears the user email.

      Returns void

      airbridge.clearUserEmail()
      
    • Sets the user phone who is logged in to the current website, in order to integrate user identity.

      Parameters

      • userPhone: string

        The user phone to set.

      Returns void

      airbridge.setUserPhone('user-phone')
      
    • Clears the user phone.

      Returns void

      airbridge.clearUserPhone()
      
    • Sets a user attribute with the given key and value.

      Parameters

      • key: string

        The key of the attribute.

      • value: unknown

        The value of the attribute.

      Returns void

      airbridge.setUserAttribute('key', 'value')
      
    • Removes a user attribute with the given key.

      Parameters

      • key: string

        The key of the attribute to remove.

      Returns void

      airbridge.removeUserAttribute('key')
      
    • Clears all user attributes.

      Returns void

      airbridge.clearUserAttributes()
      
    • Sets a user alias with the given key and value.

      Parameters

      • key: string

        The key of the alias.

      • value: string

        The value of the alias.

      Returns void

      airbridge.setUserAlias('key', 'value')
      
    • Removes a user alias with the given key.

      Parameters

      • key: string

        The key of the alias to remove.

      Returns void

      airbridge.removeUserAlias('key')
      
    • Clears all user aliases.

      Returns void

      airbridge.clearUserAlias()
      
    • Clears all user data.

      Returns void

      airbridge.clearUser()
      
    • Sets a device alias with the given key and value.

      Parameters

      • key: string

        The key of the alias.

      • value: string

        The value of the alias.

      Returns void

      airbridge.setDeviceAlias('key', 'value')
      
    • Removes a device alias with the given key.

      Parameters

      • key: string

        The key of the alias to remove.

      Returns void

      airbridge.removeDeviceAlias('key')
      
    • Clears all device aliases.

      Returns void

      airbridge.clearDeviceAlias()
      
    • Creates a touchpoint with the given options and calls the provided callback function.

      Parameters

      Returns void

      airbridge.createTouchpoint({
      defaultParams: {
      campaign: 'campaign',
      medium: 'medium',
      content: 'content',
      term: 'term',
      },
      ctaParams: {
      cta_param_1: 'cta_param_1',
      cta_param_2: 'cta_param_2',
      cta_param_3: 'cta_param_3',
      },
      }, (error, touchpoint) => {
      if (error) {
      // Handle the error
      console.error('Error creating touchpoint:', error)
      return
      }
      // Handle the created touchpoint
      console.log('Created touchpoint:', touchpoint.referrer)
      })
    • Opens the website with the URL.

      Parameters

      • url: string

        The URL to open the website.

      Returns void

      airbridge.sendWeb('https://www.example.com')
      
    • Opens the website with the URL.

      Parameters

      • url: string

        The URL to open the website.

      • callback: (error?: unknown, response?: SendWebResponse) => void

        The callback function to be called with the website URL to open.

      Returns void

      airbridge.sendWeb('https://www.example.com', (error, response) => {
      if (error) {
      // Handle the error
      console.error('Error opening website:', error)
      return
      }
      // Open the website with the response.targetUrl
      console.log('Opening website:', response.targetUrl)
      location.href = response.targetUrl
      })
    • Sets the click event to the button element with button ID to open the store deeplink.

      Parameters

      Returns void

      airbridge.setDownloads({
      buttonID: 'open-store',
      defaultParams: {
      campaign: 'campaign',
      medium: 'medium',
      content: 'content',
      term: 'term',
      },
      ctaParams: {
      cta_param_1: 'cta_param_1',
      cta_param_2: 'cta_param_2',
      cta_param_3: 'cta_param_3',
      },
      })
    • Sets the click event to the button element with button ID to open the deeplink. If options.fallbacks.ios is set to itunes-appstore, opens the store when the application is not installed. If options.fallbacks.android is set to google-play, opens the store when the application is not installed.

      Parameters

      • options: SetDeeplinksOptions

        The options to set the deeplink button.

        • buttonID: string | string[]

          The button ID(s) to add the click event.

        • Optionalfallbacks?: DeeplinkOptions["fallbacks"]
        • OptionaldefaultParams?: PlacementParameters["defaultParams"]
        • OptionalctaParams?: PlacementParameters["ctaParams"]
        • Optionalredirect?: boolean

          Whether to open the application directly without the user gesture.
          If set to true, opens the application directly without the user gesture.
          If set to false, opens the application after the user gesture in the click event.

          false
          
        • OptionaldesktopPopUp?: boolean

          Whether to open the application in new window on desktop environment.
          If set to true, opens the application in new window on desktop environment.

          false
          

      Returns void

      airbridge.setDeeplinks({
      buttonID: 'open-application',
      deeplinks: {
      ios: 'example://main',
      android: 'example://main',
      desktop: 'https://www.example.com',
      },
      fallbacks: {
      ios: 'itunes-appstore',
      android: 'google-play',
      },
      defaultParams: {
      campaign: 'campaign',
      medium: 'medium',
      content: 'content',
      term: 'term',
      },
      ctaParams: {
      cta_param_1: 'cta_param_1',
      cta_param_2: 'cta_param_2',
      cta_param_3: 'cta_param_3',
      },
      })
      airbridge.setDeeplinks({
      buttonID: 'open-application',
      deeplinks: {
      ios: 'https://www.example.com',
      android: 'https://www.example.com',
      desktop: 'https://www.example.com',
      },
      fallbacks: {
      ios: 'itunes-appstore',
      android: 'google-play',
      },
      defaultParams: {
      campaign: 'campaign',
      medium: 'medium',
      content: 'content',
      term: 'term',
      },
      ctaParams: {
      cta_param_1: 'cta_param_1',
      cta_param_2: 'cta_param_2',
      cta_param_3: 'cta_param_3',
      },
      })
    • Opens the deeplink

      Parameters

      • options: OpenDeeplinkOptions

        The options to open the deeplink.

        • type: "redirect" | "click"

          Determines the type of opening the deeplink.
          If set to redirect, opens the application directly without the user gesture.
          If set to click, opens the application after the user gesture in the click event.

        • Optionalfallbacks?: DeeplinkOptions["fallbacks"]
        • OptionaldefaultParams?: PlacementParameters["defaultParams"]
        • OptionalctaParams?: PlacementParameters["ctaParams"]
        • OptionaldesktopPopUp?: boolean

          Whether to open the application in new window on desktop environment.
          If set to true, opens the application in new window on desktop environment.

          false
          

      Returns void

      airbridge.openDeeplink({
      type: 'redirect',
      deeplinks: {
      ios: 'example://main',
      android: 'example://main',
      desktop: 'https://www.example.com',
      },
      fallbacks: {
      ios: 'itunes-appstore',
      android: 'google-play',
      },
      defaultParams: {
      campaign: 'campaign',
      medium: 'medium',
      content: 'content',
      term: 'term',
      },
      ctaParams: {
      cta_param_1: 'cta_param_1',
      cta_param_2: 'cta_param_2',
      cta_param_3: 'cta_param_3',
      },
      })
    • Opens a banner with the given options.

      Parameters

      • options: SetBannerOptions

        The options for the banner.

        • Optionaltitle?: string

          The title of the banner.

        • Optionaldescription?: string

          The description of the banner.

        • OptionalkeyColor?: string

          The key color of the banner.

        • Optionalposition?: number

          The position of the banner (1 = top, 0 = bottom).

      Returns void

      Use airbridge.openBanner() instead.

      airbridge.setBanner({
      title: 'Move to Store Banner',
      description: 'Click the button to move to the store',
      keyColor: '#0a69ff',
      position: 1, // top
      })
    • Opens a banner with the given options.

      Parameters

      • options: OpenBannerOptions

        The options for the banner.

        • title: string

          The title of the banner.

        • description: string

          The description of the banner.

        • buttonText: string

          The text for the button in the banner.

        • destination:
              | BannerWebDestinationOptions
              | BannerDownloadDestinationOptions
              | BannerDeeplinkDestinationOptions

          The destination options for the banner (web, download, or deeplink).

        • Optionalcolor?: string

          The color of the banner.

        • Optionalposition?: "top" | "bottom"

          The position of the banner (top or bottom).

        • Optionalstyles?: Record<string, Partial<CSSStyleDeclaration>>

          The custom styles for the banner.

      Returns void

      airbridge.openBanner({
      title: 'Move to Website Banner',
      description: 'Click the button to move to the website',
      buttonText: 'Move',
      color: '#0a69ff',
      position: 'top',
      destination: {
      type: 'web',
      url: 'https://www.example.com',
      },
      })
      airbridge.openBanner({
      title: 'Move to Store Banner',
      description: 'Click the button to move to the store',
      buttonText: 'Move',
      color: '#0a69ff',
      position: 'top',
      destination: {
      type: 'download',
      defaultParams: {
      campaign: 'campaign',
      medium: 'medium',
      content: 'content',
      term: 'term',
      },
      ctaParams: {
      cta_param_1: 'cta_param_1',
      cta_param_2: 'cta_param_2',
      cta_param_3: 'cta_param_3',
      },
      },
      })
      airbridge.openBanner({
      title: 'Move to Application Banner',
      description: 'Click the button to move to the application',
      buttonText: 'Open',
      color: '#0a69ff',
      position: 'top',
      destination: {
      type: 'deeplink',
      deeplinks: {
      ios: 'example://main',
      android: 'example://main',
      desktop: 'https://www.example.com',
      },
      fallbacks: {
      ios: 'itunes-appstore',
      android: 'google-play',
      },
      defaultParams: {
      campaign: 'campaign',
      medium: 'medium',
      content: 'content',
      term: 'term',
      },
      ctaParams: {
      cta_param_1: 'cta_param_1',
      cta_param_2: 'cta_param_2',
      cta_param_3: 'cta_param_3',
      },
      },
      })
    • Creates a tracking link with the given channel and options, and calls the provided success callback.

      Parameters

      • channel: string

        The channel for the tracking link.

      • options: CreateTrackingLinkOptions

        The options for the tracking link.

        • [key: string]: unknown
        • Optionalcampaign?: string
        • Optionalad_group?: string
        • Optionalad_creative?: string
        • Optionalcontent?: string
        • Optionalterm?: string
        • Optionalsub_id?: string
        • Optionalsub_id_1?: string
        • Optionalsub_id_2?: string
        • Optionalsub_id_3?: string
        • Optionalfallback_ios?: "store" | string
        • Optionalfallback_android?: "store" | string
        • Optionalfallback_desktop?: string
        • Optionalfallback_ios_store_ppid?: string
        • Optionalfallback_android_store_listing?: string
        • Optionalogtag_title?: string
        • Optionalogtag_description?: string
        • Optionalogtag_image_url?: string
        • Optionalogtag_website_crawl?: "desktop"
        • Optionalcustom_short_id?: string
        • Optionalis_reengagement?: "off" | "on_true" | "on_false"
      • onSuccess: (trackingLink: CreateTrackingLinkResponse) => void

        Callback function to be called with the created tracking link.

      Returns void

      airbridge.createTrackingLink('example', {
      campaign: 'campaign',
      ...,
      }, (trackingLink) => {
      // Handle the created tracking link
      console.log(trackingLink.shortURL)
      window.open(trackingLink.shortURL, '_blank')
      })
    • Creates a tracking link with the given channel and options, and calls the provided success and error callbacks.

      Parameters

      • channel: string

        The channel for the tracking link.

      • options: CreateTrackingLinkOptions

        The options for the tracking link.

      • onSuccess: (trackingLink: CreateTrackingLinkResponse) => void

        Callback function to be called with the created tracking link.

      • onError: (error: Error) => void

        Callback function to be called with an error if one occurs.

      Returns void

      airbridge.createTrackingLink('example', {
      campaign: 'campaign',
      ...,
      }, (trackingLink) => {
      // Handle the created tracking link
      console.log(trackingLink.shortURL)
      window.open(trackingLink.shortURL, '_blank')
      }, (error) => {
      // Handle the error
      console.error('Error creating tracking link:', error)
      })