Android SDK (v4) (Beta)

    Maven metadata URL

    Attention

    This is a guide for installing and setting up the Android SDK v4. For previous versions, refer to the Android SDK (v2) guide.

    Install the Airbridge Android SDK and implement the necessary settings following the steps below.

    Install SDK

    The Airbridge React Native SDK can be installed using the method below. After installation, you can verify whether the SDK has been properly installed through an Android SDK test.

    Install Restricted SDK

    Attention

    Install only one version of the SDK, either the general SDK or the restricted SDK.

    Depending on policies and environments, restrictions on collecting device IDs like GAID and IDFA may be required. When installing the Restricted SDK version, the device IDs are not collected.

    Install the Restricted SDK using the method below.

    Initialize SDK

    Initializing the Airbridge Android SDK in the Android Application class is recommended.

    1. Create an Application class.

    12345678
    import android.app.Application
    
    class AndroidApplication: Application() {
    
        override fun onCreate() {
            super.onCreate()
        }
    }

    2. Set the generated Application in AndroidManifest.xml.

    AndroidManifest.xml
    123
     <application
            android:name=".AndroidApplication"
            ...>

    3. Get Airbridge from the Application class.

    1
    import co.ab180.airbridge.Airbridge

    4. Add the following code snippet to the Application class file registered in AndroidManifest.xml.

    The YOUR_APP_NAME and YOUR_APP_SDK_TOKEN can be found on the [Settings]>[Tokens] page in the Airbridge dashboard.

    12345678
    override fun onCreate() {
        super.onCreate()
        // YOUR_APP_NAME: input your app name
        // YOUR_APP_SDK_TOKEN: input your app token
        val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
            .build()
        Airbridge.initializeSDK(this, option)
    }

    Attention

    Make sure that the initalizeSDK function is called within the onCreate method of the Application class for proper functionality.

    5. Set the following permissions.

    Set up SDK opt-in

    Attention

    The instructions below are optional. Proceed 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. From the moment the startTracking function is called, the SDK will start collecting events.
    1. Initialize SDK in the Application class. Prevent automatic event tracking after initialization through the autoStartTrackingEnabled.

    12345
    // Default Auto Start Tracking Enabled = true
    val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
        .setAutoStartTrackingEnabled(false)
        .build()
    Airbridge.initializeSDK(this, option)

    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.

    1234
    // Set a variable like below
    if (properties.isGDPRAccepted) {
        Airbridge.startTracking()
    }

    Set up SDK opt-out

    Attention

    The instructions below are optional. Proceed only if necessary.

    The opt-out policy allows the use of user information until the user explicitly declines.

    After setting the setAutoStartTrackingEnabled function to true, call the stopTracking function at the point where you cannot collect events. From the moment the stopTracking function is called, the SDK will stop collecting events.

    123456
    val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
        .setAutoStartTrackingEnabled(true)
        .build()
    Airbridge.initializeSDK(this, option)
    ...
    Airbridge.stopTracking()

    Set up SDK Signature

    Attention

    The instructions below are optional. Proceed only if necessary.

    With the SDK Signature, you can ensure SDK Spoofing prevention and use verified events for ad performance measurement.

    For the SDK Signature setup, the SDK Signature Credentials are required, which includes the Secret ID and the Secret. The required SDK Signature Credentials can be found in the Airbridge dashboard. For more details about the SDK Signature Credentials, refer to this Airbridge guide.

    You can set the SDK Signature by calling the setSDKSignature function above the SDK initialization code.

    1234
    val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
        .setSDKSignature("YOUR_SDK_SIGNATURE_SECRET_ID", "YOUR_SDK_SIGNATURE_SECRET")
        .build()
    Airbridge.initializeSDK(this, option)

    The information required for the setup is as follows.

    • YOUR_APP_NAME: The name of your app on Airbridge. Navigate to [Settings]>[Tokens] in the Airbridge dashboard to find it.

    • YOUR_APP_SDK_TOKEN: Android SDK Token. Navigate to [Settings]>[Tokens] in the Airbridge dashboard to find it.

    • YOUR_SDK_SIGNATURE_SECRET_ID: Secret ID. Navigate to [Management]>[Fraud Validation Rules]>[SDK Signature] in the Airbridge dashboard to find it.

    • YOUR_SDK_SIGNATURE_SECRET: Signature Secret. Navigate to [Management]>[Fraud Validation Rules]>[SDK Signature] in the Airbridge dashboard to find it.

    Deep Linking

    By setting up a deep link, you can redirect users who click on ads with tracking links to specific pages of the desired app. Based on the information collected through the tracking link, you can also track the ad performance results in Airbridge.

    When Airbridge generates a tracking link, it automatically selects and utilizes the optimal Airbridge deep link, depending on the environment. This link will be used for user redirection and is called the scheme deep link.

    Example)

    • Airbridge Deeplink: https://YOUR_APP_NAME.airbridge.io/~~~

    • Scheme Deeplink: YOUR_SCHEME://product/12345

    When the app is installed on a device and the user clicks the tracking link, the app opens through the Airbridge deep link. The Airbridge SDK converts the Airbridge deep link into a scheme deep link set on the tracking link. The converted scheme deep link is sent to the app.

    When the app is not installed on a device and the user clicks the tracking link, the Airbridge deep link is saved. After the user moves to the app store or website and the app is installed and launched, the Airbridge SDK converts the saved Airbridge deep link into a scheme deep link. The converted scheme deep link is sent to the app.

    Set up deep linking

    For the deep linking setup, the following information is required.

    • Deep link information you entered into the Airbridge dashboard

    • App page address you want to redirect users

    First, enter the deep link information into the Airbridge dashboard.

    After entering the deep link information into the Airbridge dashboard, additional setup is required to enable the following.

    • App launch with Airbridge deep links

    • User redirection with Airbridge deep links

    For detailed instructions, refer to the information below.

    Set up deferred deep linking

    When a user clicks on a tracking link with deferred deep linking capabilities and your app is not installed on the device, the Airbridge SDK retrieves the deep link as follows.

    The Airbridge.handleDeferredDeeplink function retrieves the saved Airbridge deep link and converts it into a scheme deep link to pass it to the app. Users are redirected to the intended destination using the converted scheme deep link.

    1234
    val isHandled = Airbridge.handleDeferredDeeplink {
        // when app is opened with deferred deeplink
        // show proper content using url
    }

    The Airbridge.handleDeferredDeeplink function returnstrue if it has been called for the first time after the install and waits for the Airbridge deep link to be retrieved, converts it to a scheme deep link to pass it to onSuccess. You can use this scheme deep link to send users to the intended destination.

    If there is no stored Airbridge deep link, null is passed to onSuccess. If the SDK is not initialized or if the Airbridge.handleDeferredDeeplink function has not been called for the first time, false will be returned.

    The scheme deep link is usually a URL in the form of YOUR_SCHEME://... If you use services like Meta Deferred App Links, a different form of URL may be passed.

    In-app Events

    The Airbridge SDK collects user actions from the app as per settings and sends them as in-app events.

    Send in-app events

    SDK setup for hybrid apps

    You can set up the Android SDK to handle Airbridge-related tasks occurring within the in-app website without having to change the website's code for your hybrid app.

    Use the trackEventmethod to send events. Call Airbridge to use the trackEventmethod.

    1
    import co.ab180.airbridge.Airbridge

    Call the AirbridgeCategory, AirbridgeAttribute to use the category names and attributes predefined by Airbridge.

    12
    import co.ab180.airbridge.common.AirbridgeCategory
    import co.ab180.airbridge.common.AirbridgeAttribute

    Refer to the information below about the required trackEvent function components and their types.

    12345
    fun trackEvent(
        category: String,
        semanticAttributes: Map<String, Any?>? = null,
        customAttributes: Map<String, Any?>? = null
    )

    Component

    Required or Optional

    Type

    Description

    category

    Required

    String

    Event name

    semanticAttributes

    Optional

    Map<String, Any?>

    Semantic Attributes of the event

    customAttributes

    Optional

    Map<String, Any?>

    Custom Attributes of the event

    Refer to the component definition and available strings below.

    The Standard Event Categories and Semantic Attributes provided by the SDK are as follows.

    Refer to the example codes for each data type below.

    12345678910111213
    Airbridge.trackEvent(
        "event",
        mapOf(
            AirbridgeAttribute.VALUE to 10,
        ),
        mapOf(
            "string" to "string",
            "number" to 1000,
            "boolean" to true,
            "object" to mapOf("key" to "value"),
            "array" to listOf("value"),
        )
    )

    Additional in-app event settings

    Attention

    The default settings will apply if no additional settings are configured. Proceed after reviewing whether additional settings are necessary.

    Configure additional settings for sending in-app events if necessary.

    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.

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

    12345678910111213
    Airbridge.trackEvent(
        "event",
        mapOf(
            AirbridgeAttribute.VALUE to 10,
        ),
        mapOf(
            "string" to "string",
            "number" to 1000,
            "boolean" to true,
            "object" to ["key": "value"],
            "array" to ["value"],
        )
    )

    User Data

    Airbridge sends user data along with events. User data allows for a more accurate ad performance measurement.

    Set up user ID

    User IDs refer to the user identifier used in a service. User IDs should be unique IDs that can identify unique users across websites and apps.

    #{"width":"140px"}

    Function

    #{"width":"240px"}

    Description

    Airbridge.setUserID

    Inputs user ID.

    Airbridge.clearUserID

    Deletes user ID.

    Airbridge.setUserAlias

    Adds additional identifiers. Up to 10 items can be added.
    - key: Up to 128 characters. Must follow the regular expression ^[a-zA-Z_][a-zA-Z0-9_]*$.
    - value: Up to 1024 characters.

    Airbridge.removeUserAlias

    Deletes only specified identifiers.

    Airbridge.clearUserAlias

    Deletes all additional identifiers.

    Refer to the example below.

    1234567
    // ID
    Airbridge.setUserID("testID")
    
    // alias
    Airbridge.setUserAlias("ADD_YOUR_KEY", "value")
    Airbridge.removeUserAlias("DELETE_THIS_KEY")
    Airbridge.clearUserAlias()

    Send additional user properties

    Attention

    Sensitive user information may be included. Send after a thorough review with a legal advisor.

    Send additional user information by setting user attributes.

    #{"width":"140px"}

    Function

    #{"width":"240px"}

    Description

    Airbridge.setUserEmail

    Inputs user's email. The data is hashed using SHA256.

    Airbridge.clearUserEmail

    Deletes user email.

    Airbridge.setUserPhone

    Inputs user's phone number. The data is hashed using SHA256.

    Airbridge.clearUserPhone

    Deletes user's phone number.

    Airbridge.setUserAttribute

    Adds additional user attributes. Up to 100 items can be entered.
    - key: Up to 128 characters. Must follow the regular expression ^[a-zA-Z_][a-zA-Z0-9_]*$.
    - value: Only string, number, and Boolean types are supported. Up to 1024 characters.

    Airbridge.removeUserAttribute

    Deletes only specified attributes from the additional attributes.

    Airbridge.clearUserAttributes

    Deletes all additional user attributes.

    Refer to the example below.

    1234567891011121314
    // 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", 1L)
    Airbridge.setUserAttribute("ADD_YOUR_KEY", 1f)
    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()

    When the Airbridge.setHashUserInformationEnabled function is set to false, user emails and phone numbers are transmitted without being hashed. The default setting is true.

    12345
    // Default User Info Hash Enabled = true
    val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
        .setHashUserInformationEnabled(false)
        .build()
    Airbridge.initializeSDK(this, option)

    Clear user data

    You can reset user information with the Airbridge.clearUser function.

    1
    Airbridge.clearUser()

    Additional SDK Settings

    Refer to the information below for additional SDK settings.

    Attention

    The instructions below are optional. Proceed only if necessary.

    Depending on the method of opening the link, it may be challenging to properly use the tracking link within the app.

    By using the Airbridge.click function or the Airbridge.impression function, you can properly use the tracking link within the app without sending users to an external browser.

    Attention

    When the Airbridge's Android SDK 2.18.0 or later is set up to use tracking links within the app, every time a user clicks the tracking link within the app, the Deeplink Pageview event is aggregated as Target Event. If the Deeplink Pageview event frequently occur right after the Deeplink Open event, the performance of the deep link may be affected.
    The default attribution window for Deeplink Pageviews is 3 days. If you want to change the attribution window for Deeplink Pageviews, contact your Airbridge CSM.

    Use attribution results

    Attention

    It takes some time for the Airbridge SDK to collect attribution results. We do not recommend using attribution results for functionalities requiring real-time processing.

    With the setOnAttributionReceivedfunction, you can receive the attribution results for install events.

    12345678
    val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
    	.setOnAttributionReceived(object : OnAttributionResultReceiveListener {
    		override fun onAttributionResultReceived(result: Map<String, String>) {
    			// Process attribution data
    		}
    	})
    	.build()
    Airbridge.initializeSDK(application, option)

    The values are passed as follows, based on whether or not attribution results exist.

    The Airbridge SDK collects deep link events when the app is launched through a deep link, regardless of the service that generated the deep link. If deep link events are excessively collected, you can set the setTrackAirbridgeDeeplinkOnlyEnabledfunction to true to collect only Airbridge deep links.

    12345
    // Default Track Airbridge Link Only = false
    val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
        .setTrackAirbridgeDeeplinkOnlyEnabled(true)
        .build()
    Airbridge.initializeSDK(application, option)

    Collect in-session lifecycle events

    The Airbridge SDK collects Open and Foreground events that initiate a new session. These events are not collected during an ongoing session.

    By setting the setTrackInSessionLifeCycleEventEnabled function to true, you can collect Open and Foreground events during ongoing sessions.

    All collected Foreground events are recorded as Open events.

    1234
    val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
        .setTrackInSessionLifeCycleEventEnabled(true)
        .build()
    Airbridge.initializeSDK(application, option)

    Compliance with Google DMA

    To comply with the Digital Market Act (DMA), the user consent data must be sent to Airbridge. Refer to the Airbridge user guide for more details about DMA.

    In the European Economic Area (EEA), the information on whether a user's location is in the European Economic Area and the user consent data must always be sent to Airbridge.

    1. Determine the region of the users who launch the app is located. If the region where the user launches the app is the EEA (eea=1), check if there is any previously collected user consent data. If user consent data has already been collected, proceed with step 3.

    If the region where the user launches the app is not the EEA, the user consent data collection is not required.

    Note

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

    2. If no user consent data has been collected, collect user consent through prompts or similar means. The data that needs to be collected at this stage is adPersonalization, adUserData.

    3. Before initializing the Airbridge SDK and collecting user information, send the user response data to Airbridge.

    Attention

    Pay attention to the following.

    • Use the field names specified by Airbridge: eea, adPersonalization, and adUserData.

    • Fill in 0 or 1 in accordance with the consent data collected.

    123456789101112131415161718192021
    // MainApplication.kt
    override fun onCreate() {
        super.onCreate()
        // Initialize Airbridge SDK
        val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
            // Make Airbridge SDK explicitly start tracking
            .setAutoStartTrackingEnabled(false)
            .build()
        Airbridge.initializeSDK(application, option)
    
        // Set device alias into Airbridge SDK
        // 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")
        
        // Explicitly start tracking
        Airbridge.startTracking()
    }

    Attention

    If you have set up the Meta Deferred App Link, Facebook SDK's fetchDeferredAppLink function should not be used.

    You can use deferred deep links in Meta ads using the methods below. The Airbridge SDK first collects the Meta deferred app links. If there is no Meta deferred app link, the Airbridge deferred deep link is collected.

    1. Add a repository to the project/build.gradle file.

    123456789
    allprojects {
        ...
        repositories {
            ...
            mavenCentral()
            ...
        }
        ...
    }

    2. Add the code snippet below to the dependencies block in the app/build.gradle file.

    12345
    dependencies {
        ...
        implementation 'com.facebook.android:facebook-android-sdk:latest.release'
        ...
    }

    3. Add the code snippet below to the app/res/values/string.xmlfile.

    12345
    ...
    <string name="facebook_app_id">FACEBOOK_APP_ID</string>
    <string name="facebook_client_token">FACEBOOK_CLIENT_TOKEN</string>
    ...
    

    4. Add the following <meta-data> to the <application> element in the AndroidManifest.xml file.

    12345678
    ...
    <application android:label="@string/app_name" ...> 
        ...
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
        <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
        ...
    </application>
    ...

    5. At the SDK initialization step, you can use the Meta deferred app link feature with the setAutoStartTrackingEnabledfunction. Set the setAutoStartTrackingEnabledto true.

    12345
    // Default meta Deferred App Link Enabled = false
    val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
        .setTrackMetaDeferredAppLinkEnabled(true)
        .build()
    Airbridge.initializeSDK(application, option)

    Initialize the Airbridge SDK with features being deactivated

    Attention

    If the Airbridge SDK is not activated immediately after initialization, the Install, Open, Deep link events may not be collected.

    Upon the initialization of the Airbridge SDK, all features are activated. By setting the setSDKEnabledfunction to false, you can initialize the Airbridge SDK with all features being deactivated.

    1234
    val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
        .setSdkEnabled(false)
        .build()
    Airbridge.initializeSDK(application, option)

    You can also verify the activation status of the Airbridge SDK as below and activate or deactivate all features.

    123456789
    // Checks whether the SDK is currently enabled.
    // @return Boolean
    Airbridge.isSDKEnabled()
    
    // Enables the SDK.
    Airbridge.enableSDK()
    
    // Disables the SDK.
    Airbridge.disableSDK()

    Meta Install Referrer collection settings

    This setup is required to collect the Meta Install Referrer. You send the Meta app ID to the setMetaInstallReferrerfunction in the SDK initialization stage.

    1234
    val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
        .setMetaInstallReferrer("YOUR_FACEBOOK_APP_ID")
        .build()
    Airbridge.initializeSDK(application, option)

    After the setup, you need to enter the decryption key into the Airbridge dashboard to view the decrypted Meta Install Referrer. Refer to the Airbridge user guide to learn how to enter the decryption key.

    Set up Uninstall event tracking

    Airbridge sends a silent push daily between 3:00 PM and 4:00 PM (UTC) to users whose app event has been collected at least once in the last 6 months to check for uninstalls. Uninstall events can be monitored through Airbridge reports and raw data export files.

    For the detailed setup method and explanation, refer to the following article.

    Integrate with third-party solutions

    For some third-party solutions, SDK setup is required. We recommend completing the SDK setup for the third-party solution integration before collecting data with the Airbridge SDK.

    Refer to the articles listed below for the integration with third-party solutions.

    SDK logs

    The logs provided by the Airbridge SDK consist of the following levels: Debug, Info, Warning, Error, and Fault. Debug is the least fatal, and Fault is the most fatal level.

    The Airbridge SDK, by default, provides log levels, including Warning, Error, and Fault. You can check logs from the log level you enter through the

    Enter the log level into the setLogLevelfunction to check the log level up to the Fault level.

    12345
    // Default log level = Log.INFO
    val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
        .setLogLevel(AirbridgeLogLevel.DEBUG)
        .build()
    Airbridge.initializeSDK(this, option)

    Was this page helpful?

    Have any questions or suggestions?