Android SDK

    SDK Setup


    Download v2.22.2

    SDK Installation

    Installation with Gradle

    Add the following repository under the allproject/repositores block in your project/build.gradle file.

    If you're using Android Studio Arctic Fox (2020.3.1) or to create your project, or if your repository settings are done within the settings.gradle file, add the following to your project/settings.gradle file under the dependencyResolutionManagement/repositories block.

    Add the following to the dependencies block in your app/build.gradle file

    Direct Installation with an AAR File

    The Airbridge SDK uses JetBrains' Kotlin and Coroutines libraries for better stability and productivity. Please add following dependency libraries in your project when setting up using an ARR file.

    Library

    Link

    Airbridge SDK

    Download

    JetBrains Java Annotations

    Download

    Kotlin Standard Library

    Download

    Kotlinx Coroutines Core

    Download

    Kotlinx Coroutines Android

    Download

    Airbridge Android SDK requires Kotlin stdlib and Kotlinx coroutines library version 1.4 or higher.

    Project Setup

    Min SDK 16

    Add Permissions

    Please add the following permissions in your AndroidManifest.xml file

    Initialization

    Please add the following code under the onCreate method of the Application class file registered in the AndroidManifest.xml file.

    Attention

    For proper operation, please make sure that the init method is called at the time of onCreate of the Application class.

    You can find YOUR_APP_NAME and YOUR_APP_SDK_TOKEN in the "Airbridge Dashboard → Settings → Tokens" tab.

    Testing the SDK

    Once the basic installation and configuration of the Airbridge SDK is complete, you can test whether it has been correctly setup through the following methods.

    Check in the Airbridge Dashboard

    1. Install and open the app on the device that you want to test

    2. Go to "Airbridge dashboard → Raw Data → App Real-time Logs"

    3. Enter Google Advertising ID of the device in the search box

    Please re-check the guide above if you do not see any install event with your Google Advertising ID

    You can find the Google Advertising ID of a device at Settings → Google → Ads → Your advertising ID.

    Check in LogCat

    Use the following method if you want to use LogCat to see a more detailed log of the app.

    Attention

    Since this method may expose user information, please make sure the method is executed only for the Build.DEBUG case.


    Dashboard Setup

    The following information must be registered at the "Airbridge dashboard → Tracking Link → Deep Link"

    • URI Scheme

    • sha256_cert_fingerprints

    URI Scheme Setup

    Enter the URI scheme that will be used, including ://, in the "Android URI Scheme" area as shown in the picture above. (e.g. example://yoururischeme://)

    Attention

    Airbridge supports lowercase, numbers, and some special characters (-+.) for URI Schemes.

    Register Fingerprint

    Follow the below steps to obtain the sha256_cert_fingerprint.

    1. Prepare the keystorefile that you used to register your app with Google Play Store.

    2. Execute the following command in Linux.

    3. Copy the SHA256value under the Certificate Fingerprints section and paste it under Android sha256_cert_fingerprintsas shown in the picture above.

    Project Setup

    Intent Filter Setup

    Follow these steps to setup the intent-filter

    1. Open AndroidManifest.xml

    2. Add the following intent-filterto the activitythat will process the deep link.

    • YOUR_APP_NAME.deeplink.page: Airbridge App Links Version 2

    • YOUR_APP_NAME.airbridge.io: Airbridge App Links Version 1

    • YOUR_APP_URI_SCHEME: URI Scheme of the deep link (e.g. abc://)

    Custom Domain Setup

    The deeplink.page or abr.ge domains are available when creating a tracking link at the Airbridge dashboard. Customized URLs such as go.my_company.com/abcd can also be used as tracking links to improve the branding and CTR (Click Through Rate).

    1. Please follow this guide to setup custom domains.

    2. Create a /res/values/airbridge.xml file and edit it as below

    3. Add the following intent-filterto the activitythat will process the deep link.

    Attention

    YOUR_CUSTOM_DOMAIN should match the information in the Airbridge dashboard

    The edit below is needed to process the deep link as defined by the intent-filter above.

    In the general case of a deferred deep link in Airbridge SDK, the intent-filter automatically calls the corresponding activity and can be processed in the same way as a deep link callback.

    When the corresponding activity is called through an Airbridge deferred deep link, the deferred=true query parameter is also passed on.

    You can use the following method if you do not want the deferred deep link to automatically call an activity, or want to process a specific job with the information obtained through the deferred deep link.

    Click on your URI scheme to test if your deep link has been properly set up in the Airbridge SDK.

    • YOUR_APP_URI_SCHEME://

    The results will show on the "Airbridge dashboard → Raw Data → App Real-time Log" tab if everything is working.

    User Setup


    User Identifier Setup

    To measure the fragmented contributions of users between web and app, Airbridge collects the following user identifier information.

    • User Email: Email address

    • User Phone: Phone number

    • User ID: Unique User ID (The ID value that specifies the user must be the same in both web and mobile)

    • User Alias: Identifiers that can represent users (e.g. loyalty program ID, affiliate integrated ID, etc)

    The user's email and phone numbers are hashed (SHA256) by default and then sent to servers.

    You can set the user identifier as below for the SDK.

    Name

    Description

    Limitations

    Email

    User email

    Hashed by default
    (SHA256, can be disabled)

    Phone

    User phone number

    Hashed by default
    (SHA256, can be disabled)

    Id

    User ID

    -

    Alias

    User alias

    - Maximum 10 aliases
    - "key"type is String, maximum 128 characters
    - "key"must satisfy ^[a-z_][a-z0-9_]*$regex
    -"value"type is String, maximum 1024 characters

    Once the user identifier has been setup, all events will be forwarded with the corresponding identity information.

    User Attributes Setup

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

    Name

    Description

    Limitations

    setAttribute

    User attribute

    - Maximum 100 attributes
    - "key" type is string, maximum 128 characters
    - "key" must satisfy ^[a-z_][a-z0-9_]*$regex
    - "value" type is primitive or string
    - Maximum 1024 characters when "value" is string

    Test User Information Setup

    Check your user information settings at "Airbridge Dashboard → Raw Data → App Real-time Log".

    Device Setup


    Setup Device Alias

    Setup a device alias through the Airbridge SDK. The alias will be sustained even after the app closes, unless otherwise deleted.

    Method

    Description

    setDeviceAlias(key: String, value: String)

    Add the key value pair to the device identifier.

    removeDeviceAlias(key: String)

    Delete the corresponding device alias.

    clearDeviceAlias()

    Delete all device aliases.

    Event Setup


    All events called by the Airbridge SDK can be sent with the following fields.

    Name

    Type

    Description

    EventCategory

    String

    Name of the event

    Required

    event_action

    String

    Event attribute 1

    event_label

    String

    Event attribute 2

    eventValue

    Number

    Event attribute value

    eventAttributes

    Map<String, Object>

    Custom attributes

    semanticAttributes

    Semantic attributes class

    Semantic attributes

    Below is an example of how you can send a standard event using the Airbridge SDK.

    If your application has specific needs that are not covered by a standard event category, you can log custom events as below.

    Please refer to guide for more details on semantic attributes supported by the Airbridge SDK.

    Alternatively, you can pre-define classes and inherit them depending on the event your app needs.

    Sending Standard Events

    User Sign up

    User Sign in

    User Sign out

    View Home Screen

    View Search Results

    View Product List

    View Product Details

    Add to Cart

    Order Complete

    Verify Event Transmission

    Event information sent from the Airbridge SDK should be seen in the "Airbridge dashboard → Raw Data → App Real-time Log" tab.

    Advanced Setup


    SDK Signature Setup

    Protection against SDK spoofing is available once you set up the app's SDK signature. Settings can be changed by calling setSDKSignatureSecret before the SDK initialization code.

    Please ask your CSM for the "SDK Signature Secret ID" and "SDK Signature Secret" values.

    User Identifier Hash Setup

    If you want to send user identity information without hashing it for internal data analysis, you can disable hashing by turning off the following option.

    Attention

    Other security measures must be taken internally when sensitive personal information such as "User Email" and "User Phone" is being handled.

    Session Timeout Settings

    Airbridge SDK does not resend an app open event if the user relaunches the app within the set session time. It will only send an app open event when the user opens the app after the set session time.

    Privacy Protection

    Use this function if privacy laws apply, and data should only be collected and transferred with consent. (e.g GDPRCCPA)

    It may be difficult to see the re-engagement performance through Airbridge if there are too many deep link actions within the advertiser's app. The following option can be used to receive deep link events for Airbridge deep links only.

    This option will measure deep links only if the following requirements are met.

    • The app is opened through a airbridge.iolink

    • The app is opened through a deeplink.pagelink

    • The app is opened through a Custom Domain Setup that is registered on the Airbridge dashboard

    • The app is opened through a link that contains airbridge_referrerinformation in the query

    The settings below will allow Airbridge SDK to utilize Facebook's deferred app link information.

    Reference - https://developers.facebook.com/docs/app-events/getting-started-app-events-android Reference - https://developers.facebook.com/docs/app-ads/deep-linking

    Add the following repository to the project/build.gradle file.

    Add the following under the dependencies block of the app/build.gradle file.

    Add the following string in the app/res/values/string.xml file.

    Add the following meta-data under the application element in the AndroidManifest.xml file.

    Set the below option to true.

    App Uninstallation Tracking

    App uninstallation tracking through Firebase Messaging is supported by Airbridge Android SDK v2.6.0 and above.

    Please refer to this page for more information on app uninstallation tracking.

    User Location Information Collection

    Airbridge SDK can collect user location information through the following method.

    Attention

    Location information must be collected for legal purposes through legal methods.

    Attention

    Airbridge SDK collects LastKnownLocation information. If the GPS information is not obtained, the value may not exist even if the corresponding permissions and settings are complete.

    Inflow Measurement Per App Market

    If advertisers need to analyze their application inflow performance for each market separately(e.g. Google Play Store, One Store, Huawei Store), you can set identifiers for each application and it will be reflected on the Airbridge dashboard.

    Setup via AndroidManifest.xml

    Insert the app market's name(e.g. playStoreoneStorehuaweiStore) at andriod:value.

    Setup via AirbridgeConfig

    Insert the app market's name(e.g. playStoreoneStorehuaweiStore) at setAppMarketIdentifier.

    The data can be utilized at the Airbridge dashboard through "Reports → Actuals → GroupBy → Event Property → App Market Identifier" and "Raw Data → App Raw Data → Export Raw Data → Select Property → App Market Identifier".

    Installations per App Market

    Error Log Collection

    Error logs of the SDK are sent to the Airbridge server to improve the quality of the Airbridge SDK. These error logs only include the SDK's internal operations. You can disable this by turning off the following option.

    Event Buffer Limit

    When an event transmission failure occurs, the Airbridge SDK will store the event and retry at a later time. The following settings will allow you to limit the storage used for such events.

    Event buffer size is slightly smaller than the actual size of the data due to metadata management.

    Attribution Result Callback Setup

    Get attribution result data using the Airbridge SDK.

    • Below is a list of data fields that will be retrieved through the callback.

    Field

    Description

    attributedChannel

    Channel (String)

    attributedCampaign

    Campaign (String)

    attributedAdGroup

    Ad Group (String)

    attributedAdCreative

    Ad Creative (String)

    attributedContent

    Content (String)

    attributedTerm

    Keyword (String)

    attributedSubPublisher

    Sub Publisher (String)

    attributedSubSubPublisher1

    Sub-sub Publisher 1 (String)

    attributedSubSubPublisher2

    Sub-sub Publisher 2 (String)

    attributedSubSubPublisher3

    Sub-sub Publisher 3 (String)

    • If the event is unattributed, below is an example of the response you'll get.

    Guidelines for using attribution result data

    • Attribution data exists

    1. Attribution data is forwarded within 40 seconds of SDK initialization.

    2. If the app was closed and attribution data wasn't received, attribution data is forwarded within 40 seconds when the app is opened again.

    3. On very rare occasions, attribution data could take up to 5 minutes to be received.

    • Attribution data does not exist

    1. Attribution data will be received 3 hours after SDK initialization.

    It is not recommended to utilize these attribution values for real-time processing

    Event Transmission Interval

    It is possible to setup event transmission intervals using the below code.

    Attention

    An IllegalArgumentExcpeionruntime error will occur if setEventTransmitIntervalis set to a negative number.

    Lifecycle Event Collection Within Session

    The following code allows you to collect lifecycle events (ORGANIC_REOPENFOREGROUND) within the session timeframe.

    Delete Unprocessed Events

    Empty the device's internal DB of unprocessed events that were not sent to Airbridge.

    Redirect users to other pages without going through a browser by using the below feature.

    Attention

    Custom domain tracking links with custom short IDs can't be used.

    Deactivate Airbridge

    All Airbridge functions can be turned off.

    Attention

    If setResetEventBufferEnabled is set to true and setSdkEnabled is set to false, then setSdkEnabled is prioritized and setResetEventBufferEnabled isn't processed.

    Hybrid App Setup


    While basic events (e.g. "install", "open", "deep link open") can be automatically tracked by only installing the Android SDK in your hybrid app, in-app events (e.g. sign-up, purchase, etc.) cannot be tracked as they are actually in-browser events that occur within a website of the WebView environment. Airbridge provides a simpler way to track in-app events by enabling the Android SDK to automatically pull all events from the web SDK that is installed on the website of the WebView environment. This replaces the hassle of having to create bridge functions between native and WebView environments.

    Attention

    Please note that in order to utilize this feature, both SDKs must be installed; Android SDK on the mobile native environment and web SDK on the website of the WebView environment.

    Sending Events in WebView Environments

    Reference - Building Web Apps in WebView

    Reference - Understanding Android WebView Javascript Interface

    Please call the Airbridge::setJavascriptInterface method in the target WebView as below.

    You can find YOUR_WEB_TOKEN in the "Airbridge dashboard → Settings → Tokens" tab

    Setup the SDK on the actual web page by following the Web SDK guide

    Troubleshooting


    Dependencies

    java.lang.NoClassDefFoundError: kotlin/coroutines/AbstractCoroutineContextKey Error

    Reference - https://github.com/Kotlin/kotlinx.coroutines/issues/1879

    According to @qwwdfsad, the use of "kotlin-stdlib 1.3.70" and above is enforced when using "kotlinx-coroutines-core 1.3.5" and above.

    Make sure that you're using "kotlin-stdlib 1.3.70" and above if you're using "kotlinx-coroutines-core 1.3.5" and above through the gradlew dependencies command.

    Auto Backup

    Reference - https://developer.android.com/guide/topics/data/autobackup

    Airbridge SDK defines airbridge_auto_backup_rules.xml in AndroidManifest.xml to prevent automatic replication of internal data. If you need Auto Backup for your Android app, you have to merge with airbridge_auto_backup_rules.xml file yourself

    When errors like Manifest merger failed : Attribute application@fullBackupContent value=(true) occur, please add the following rules in your backup_rules.xml file and add tools:replace="android:fullBackupContent" inside application element

    Airbridge SDK defines airbridge_auto_backup_rules.xml in AndroidManifest.xml to prevent automatic replication of internal data. You may have to configure your auto backup rules if your app uses auto backup, which in turn might cause conflicts such as Manifest merger failed : Attribute application@fullBackupContent value=(true).

    If such errors occur, you will need to set tools:replace="android:fullBackupContent" under the application element and merge the following rules to your backup_rules.xml file.

    Below are the auto backup rules defined in the Airbridge SDK.

    Was this page helpful?

    Have any questions or suggestions?