Android SDK Legacy

❗️

The document is Airbridge Android 1 version guide

We are not recommend to use this for proper operation and stability

Install

1. build.gradle

Open build.gradle file from project’s app module folder (usually named app/) and insert the following into dependencies.

dependencies {
    ...
    implementation 'io.airbridge:sdk-android:1.8.0'
    implementation 'com.android.installreferrer:installreferrer:1.1'
    ...
}

If you are in an environment where you cannot use Gradle or the Internet, please check Advanced - SDK Direct Install section.

2. AndroidManifest.xml

Please add the following permissions to the app/src/main/AndroidManifest.xml file.

...
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
...

3. Proguard

If you are using Proguard,
please add following commands to the app/proguard-rules.pro file

-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {public *;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info { public *;}
-keep class com.android.installreferrer.api.InstallReferrerClient {public *;}
-keep class com.android.installreferrer.api.InstallReferrerClient$newBuilder { public *;}
-keep class com.android.installreferrer.api.InstallReferrerClient$Builder { public *;}
-keep class com.android.installreferrer.api.ReferrerDetails {public *;}
-keep class com.android.installreferrer.api.InstallReferrerStateListener {public *;}
-keep class io.airbridge.deviceinfo.** { *; }
-keepclassmembers class io.airbridge.** { public *; }
-keep public class io.airbridge.**

4. MainApplication.java

Add the following code to the import section of the app/src/main/java/.../MainApplication.java

import io.airbridge.*;

Add the following code to the onCreate section of the app/src/main/java/.../MainApplication.java

public void onCreate() {
    super.onCreate();
    ...
    AirBridge.init(this, "[AppName]", "[AppToken]");
}
override fun onCreate() {
    super.onCreate()
    ...
    AirBridge.init(this, "[App Name]", "[App Token]")
}

You can find the "App Name" in Airbridge dashboard's 'App Setting > App Info'
And you can find the "App Token" in Airbridge dashboard's 'App Setting > Tokens Management'

Install - DeepLink - Registration

egister your app's information in Airbridge dashboard to use the deeplink feature.

Access the dashboard and click the Deeplinks menu in the sidebar. The following screen will appear afterwards.

  1. Enter the desired scheme in the Android URL scheme area of the Deeplink registration part picture by attaching "://"

example) scheme://

Applinks

  1. Prepare the signing key you used when signing up for the Google Play Store.

  2. Run the following code.

keytool -list -v -keystore my-release-key.keystore
  1. Copy the SHA256 column of the certificate fingerprints and Enter Android sha256_cert_fingerprints area of the deeplink registration part.

ex) 14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5

Install - Deeplink - code

AndroidManifest.xml

  1. Open app/src/main/AndroidManifest.xml file.
  2. Insert the following to the intent-filter of Activity, which opens with a deeplink.
<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data android:scheme="http" android:host="YOUR_APP_NAME.deeplink.page" />
    <data android:scheme="https" android:host="YOUR_APP_NAME.deeplink.page" />
</intent-filter>
<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data android:scheme="http" android:host="YOUR_APP_NAME.airbridge.io" />
    <data android:scheme="https" android:host="YOUR_APP_NAME.airbridge.io" />
</intent-filter>
<intent-filter>
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data android:scheme="EXAMPLE_SCHEME" />
</intent-filter>

Enter the app name to YOUR_APP_NAME

Enter the scheme value set in the dashboard to EXAMPLE_SCHEME

Fetch Deeplink

Please enter the following code in the onResume section of Activity that opens with a deeplink.

@Override
protected void onResume() {
    super.onResume();

    AirBridge.getDeeplink().fetch(getIntent())
            .onSuccess((deeplink) -> {
                // when deeplink exist
                Log.d("deeplink", "success : " + deeplink);
            })
            .onComplete(() -> {
                // when deeplink exist
                // when deeplink not exist
                // when there are no error
                Log.d("deeplink", "complete");
            })
            .onError((error) -> {
                // when there are error
                Log.d("deeplink", "error : " + error.getMessage());
            });
}

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    setIntent(intent);
}
override fun onResume() {
    super.onResume()
    
    AirBridge.getDeeplink().fetch(getIntent())
            .onSuccess { deeplink ->
                // when deeplink exist
                Log.d("deeplink", "success : " + deeplink);
            }.onComplete {
                // when deeplink exist
                // when deeplink not exist
                // when there are no error
                Log.d("deeplink", "complete");
            }.onError { error ->
                // when there are error
                Log.d("deeplink", "error : " + error.getMessage());
            }
}

override fun onNewIntent(intent: Intent?) {
    super.onNewIntent(intent)
    
    setIntent(intent)
}

If the app is opened with a deeplink, onSuccess and onComplete function is called.

If the app is opened without a deeplink, only onComplete function is called.

If the app is opened with a deeplink, but error occurs, onError function is called.

Install - Deeplink - Custom (Option)

Tracking Link - Custom Domain

If you have set up a custom domain of tracking link, set it as follows.

  1. Create file res/values/airbridge.xml
  2. Add the following values.
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="ExtraTranslation" >
    <string-array name="co_ab180_airbridge_trackinglink_customDomains">
        <item>example.com</item>
    </string-array>
</resources>

Insert the custom domain you set to example.com section.

Deeplink - Custom Domain

You can change the shape of the deeplink that occurs on the onSuccess.

  1. Create file res/values/airbridge.xml
  2. Add the following values.
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="ExtraTranslation" >
    ...
    <string name="co_ab180_airbridge_deeplink_scheme">
        example
    </string>
    <string name="co_ab180_airbridge_deeplink_host">
        example.com
    </string>
</resources>

If set as above, deeplink of onSuccess turn

https://appname.airbridge.io/... into

example://example.com/...

Deepink - Custom Domain and Tracking Link - Custom Domain must not be the same.

Verify Installation Completion

  1. Delete the app from the test device.
  2. Reinstall the app and run it on the satest device.
  3. Airbridge Dashboard → App choose → Log Data → Click the Realtime Log button.
  4. Enter Android GAID into 'Device UUID input'
  • If the data does not show up in real-time logs, please check again that the SDK is installed as directed in the installation section.
  • Log impressions can be delayed by up to 5 minutes.
  • Android GAID can be found Settings -> Google Settings -> Ads -> Your advertising ID

In-App Event

You can measure various user journey events through the Android SDK.

There are 9 basic events related to users' information and e-commerce user journeys. Custom events can be additionally defined as well.
Information that is attached to all events can be additionally added.

You would be able to track and analyze more accurate statistics if you include more event information.

In-App Event - user

User in-app events are a component of cross-platform user matching

Please include at least one user information if possible.

When a sign up and sign in event occurs,

All events are recorded as being triggered from that user until a sign-out event occurs.

If a sign out event occurs,

All events until the next sign-in event are recorded without that user-related data.

Email and phone user information is by default transmitted in a hashed format (SHA256).

Sign Up

If the user is signing up, send SignUpEvent.

Constructor

Name

Parameter

Description

SignUpEvent

Empty user signup event

Method

Name

Parameter

Description

setUserId

String userId
User's ID

Set the user's ID

setUserEmail

String userEmail
User's Email

Set the user's Email

setUserPhone

String userPhone
User's Phone

Set the user's Phone

Code Example

SignUpEvent event = new SignUpEvent()
        .setUserId("test-user-id")
        .setUserEmail("[email protected]")
        .setUserPhoneNumber("000-0000-0000");

AirBridge.getTracker().sendEvent(event);
val event = SignUpEvent()
        .setUserId("test-user-id")
        .setUserEmail("[email protected]")
        .setUserPhoneNumber("000-0000-0000");

AirBridge.getTracker().sendEvent(event)

Sign In

If the user is signing in, send SignInEvent.

Constructor

Name

Parameter

Description

SignInEvent

Empty user signin event

Method

Name

Parameter

Description

setUserId

String userId
User's ID

Set the user's ID

setUserEmail

String userEmail
User's Email

Set the user's Email

setUserPhone

String userPhone
User's Phone

Set the user's Phone

Code Example

SignInEvent event = new SignInEvent()
        .setUserId("test-user-id")
        .setUserEmail("[email protected]");
        .setUserPhoneNumber("000-0000-0000");

AirBridge.getTracker().sendEvent(event);
val event = SignInEvent()
        .setUserId("test-user-id")                    
        .setUserEmail("[email protected]")
        .setUserPhoneNumber("000-0000-0000");

AirBridge.getTracker().sendEvent(event)

Sign Out

If the user logs out, send SignOutEvent.

Constructor

Name

Parameter

Description

SignOutEvent

Empty user signout event

Code Example

SignOutEvent event = new SignOutEvent()

AirBridge.getTracker().sendEvent(event);
val event = SignOutEvent()

AirBridge.getTracker().sendEvent(event)

In-App Event - commerce

Tracks the user's commerce-related behavior.

Product class

This is about product class

Constructor

Name

Parameter

Description

Product

Empty product

Method

Name

Parameter

Description

setProductId

String productId
Unique ID of the product

Set a unique ID for a product

setName

String name
Name of the product

Set product name

setCurrency

String currency
Currency ot the product

Set product currency
Complies with ISO 4217 standard

setPrice

Integer price
Price of product

Set product price

setQuantity

Integer quantity
Quantity of product

Set product quantity

setPositionInList

Integer positionInList
Position of items in list

Set position of items in list

Code Example

Product product = new Product();
product.setProductId("product_id_100600");
product.setName("Apple MacBook Pro");
product.setPrice(2160000);
product.setCurrency("KRW");
product.setQuantity(2);
product.setPositionInList(0);
val product = Product()
product.productId = "product_id_100600"
product.name = "Apple MacBook Pro"
product.price = 2160000f
product.currency = "KRW"
product.quantity = 2
product.positionInList = 0

HomeView Event

If the user navigates to the app's home screen, please send HomeViewEvent.

Constructor

Name

Parameter

Description

HomeViewEvent

When user navigates to the app's home screen

Code Example

HomeViewEvent event = new HomeViewEvent();
AirBridge.getTracker().sendEvent(event);
val event = HomeViewEvent()
AirBridge.getTracker().sendEvent(event)

ProductList Event

When a user queries the product list, please send ProductListViewEvent.

Constructor

Name

Parameter

Description

ProductListViewEvent

Empty product list inquiry event

ProductListViewEvent

String listId
Unique ID of Product List
List<Product> products
Product List

Events with IDs and lists of product listing

ProductListViewEvent

String listId
Unique ID of Product List
Product product
Product

Events with IDs and lists of product listings

Method

Name

Parameter

Description

setListId

String listId
Unique ID of Product List

Unique ID of Product List

addProduct

Product product
Product

Add product to the product list

addProducts

List<Product> products
Product List

Add item list to product list

Code Example

// Create product information
Product product1 = new Product();
product1.setProductId("product_id_100600");
product1.setName("Apple MacBook Pro");
product1.setPrice(2160000);
product1.setPositionInList(1);

Product product2 = new Product();
product2.setProductId("product_id_100800");
product2.setName("Samsung Notebook5");
product2.setPrice(1420000);
product2.setPositionInList(2);

// Create product list
List<Product> products = Arrays.asList(product1, product2);

// Create ProductListViewEvent
ProductListViewEvent event = new ProductListViewEvent("list_id_200400", products);

// Send event
AirBridge.getTracker().sendEvent(event);
// Create product information
val product1 = Product()
product1.productId = "product_id_10600");
product1.name = "Apple MacBook Pro"
product1.price = 2160000f
product1.positionInList = 1

val product2 = Product()
product2.productId = "product_id_100800"
product2.name = "Samsung Notebook5"
product2.price = 1420000f
product2.positionInList = 2

// Create product list
val products = Arrays.asList(product1, product2)

// Create ProductListViewEvent
val event = ProductListViewEvent("list_id_200400", products)

// Send event
AirBridge.getTracker().sendEvent(event)
  • If the user scrolls through the list and loads new information
    It is recommended that you separately generate and send the event with the loaded product information.

SearchResult Event

If the user is searching for a product, please send SearchResultViewEvent.

Constructor

Name

Parameter

Description

SearchResultViewEvent

Empty search results event

SearchResultViewEvent

String query
Search word
List<Product> products
Search result list

Search results with search queries and product listings

SearchResultViewEvent

String query
Search word
Product product
Search result list

Search results with search terms and product

Method

Name

Parameter

Description

setQuery

String query
Search word

Set query information

addProduct

Product
Product

Add product as a result of search

addProducts

List<Product>
Product List

Add product list as search result

Code Example

SearchResultViewEvent event = new SearchResultViewEvent ("24inch monitor", products);

AirBridge.getTracker().sendEvent(event);
val event = SearchResultViewEvent("24inch monitor", products)

AirBridge.getTracker().sendEvent(event)

Product Detail event

If the user views more product details, please send ProductDetailsViewEvent.

Constructor

Name

Parameter

Description

ProductDetailsViewEvent

Empty product detail page inquiry Event

ProductDetailsViewEvent

List<Product>
Product List

Product detail page view for multiple products Event

ProductDetailsViewEvent

Product
Product

Product detail page view event for single item

Code Example

ProductDetailsViewEvent event = new ProductDetailsViewEvent(product);

AirBridge.getTracker().sendEvent(event);
val event = ProductDetailsViewEvent(products)

AirBridge.getTracker().sendEvent(event)

Add to Cart Event

If the user is adding items into their shopping cart, please send AddedToCartEvent.

Constructor

Name

Parameter

Description

AddedToCartEvent

Add to cart

AddedToCartEvent

String cartId
Unique ID of the cart
List<Product> products
Product List

AddedToCartEvent contains cartId and product list

AddedToCartEvent

String cartId
Unique ID of the cart
Product product
Product

AddedToCartEvent contains cartId and product list

Method

Name

Parameter

Description

setCartId

String cartId
Unique ID of the cart

Set Unique ID of the cart

addProduct

Product
Product

Add item to the cart

addProducts

List<Product> products
Product List

Add item list to the cart

setCurrency

String

Set product currency
Complies with ISO 4217 standard

setTotalValue

Float

Set the total amount of items to add to your cart

Code Example

Product product1 = new Product();
product1.setProductId("product_id_100600");
product1.setName("Apple MacBook Pro");
product1.setPrice(2160000);
product1.setPositionInList(1);

Product product2 = new Product();
product2.setProductId("product_id_100800");
product2.setName("Samsung Notebook5");
product2.setPrice(1420000);
product2.setPositionInList(2);

List<Product> products = Arrays.asList(product1, product2);

AddedToCartEvent event = new AddedToCartEvent()
       .setCartId("cart_id_51243")
       .addProducts(products)
       .setCurrency("KRW")
       .setTotalValue(3580000);

AirBridge.getTracker().sendEvent(event);
val product1 = Product()
product1.productId = "product_id_100600"
product1.name = "Apple MacBook Pro"
product1.price = 2160000f
product1.positionInList = 1

val product2 = Product()
product2.productId = "product_id_100800"
product2.name = "Samsung Notebook5"
product2.price = 1420000f
product2.positionInList = 2

val products = Arrays.asList(product1, product2)

val event = AddedToCartEvent()
        .setCurrency("card_id_51243")
        .addProducts(products)
        .setCurrency("KRW")
        .setTotalValue(3580000f)

AirBridge.getTracker().sendEvent(event)

Purchase Event

If the user pays, please send PurchaseEvent.

Constructor

Name

Parameter

Description

PurchaseEvent

Purchase event

PurchaseEvent

List<Product> products
Product List

Payment events for multiple product

PurchaseEvent

Product product
Product

Payment events for single product

Method

Name

Parameter

Description

addProduct

Product product
Product

Add paid product

addProducts

List<Product> product
Product List

Add paid products

setInAppPurchase

Boolean isInAppPurchase
In-app payments

Set in-app payments

setTotalValue

Float totalValue
Total payment amount

Set total payment amount

setTransactionId

String transactionId
Unique ID of payment

Set unique ID of payment

setCurrency

String currency
Currency ot the product

Set product currency
Complies with ISO 4217 standard

Code Example

Product product1 = new Product();
product1.setProductId("product_id_100600");
product1.setName("Apple MacBook Pro");
product1.setPrice(2160000);
product1.setPositionInList(1);

Product product2 = new Product();
product2.setProductId("product_id_100800");
product2.setName("Samsung Notebook5");
product2.setPrice(1420000);
product2.setPositionInList(2);

List<Product> products = Arrays.asList(product1, product2);

PurchaseEvent event = new PurchaseEvent(products)
        .setTransactionId("transact-purchase-01")
        .setInAppPurchaseed(true)
        .setCurrency("KRW")
        .setTotalValue(3580000);

AirBridge.getTracker().sendEvent(event);
val product1 = Product()
product1.productId = "product_id_100600"
product1.name = "Apple MacBook Pro"
product1.price = 2160000f
product1.positionInList = 1

val product2 = Product()
product2.productId = "product_id_100800"
product2.name = "Samsung Notebook5"
product2.price = 1420000f
product2.positionInList = 2

val products = Arrays.asList(product1, product2)

val event = PurchaseEvent(products)
        .setTransactionId("transact-purchase-01")
        .setInAppPurchaseed(true)
        .setCurrency("KRW")
        .setTotalValue(3580000f)

AirBridge.getTracker().sendEvent(event)

In-App Event - custom

In-app events can be customly defined and used.

Constructor

Name

Parameter

Description

GoalEvent

String category
Event Name

Custom events that contain category

Method

Name

Parameter

Description

setCategory

String

Event Name

setAction

String

Event action value

setLabel

String

Event label value

setValue

Integer

Event custom value

setCustomAttribute

String, Object

Event custom information

Code Example

GoalEvent event = new GoalEvent("category")
        .setAction("action")
        .setLabel("label")
        .setValue(3412);

AirBridge.getTracker().sendEvent(event);
val event = GoalEvent("category")
        .setAction("action")
        .setLabel("label")
        .setValue(3412)

AirBridge.getTracker().sendEvent(event)

For more information on Category, Action, Labels, see Classification In-App event part.

Additional Collection

You can gather more additional information.

Open & Track deeplink on App

You can use the code below to perform deeplink actions on the App and track the behavior.

// if AirBridge.init() is not called, call on MainApplication#onCreate
AirBridge.initPlacement();

AirBridge.getPlacement().click("https://abr.ge/~~~", "ablog://main", "https://airbridge.io");
AirBridge.getPlacement().impression("https://abr.ge/~~~");
// if AirBridge.init() is not called, call on MainApplication#onCreate
AirBridge.initPlacement()

AirBridge.getPlacement().click("https://abr.ge/~~~", "ablog://main", "https://airbridge.io")
AirBridge.getPlacement().impression("https://abr.ge/~~~")

If AirBridge.init() is called, you do not need to call AirBridge.initPlacement().

If you have not called AirBridge.init() please call AirBridge.initPlacement().

click

click function +1 click statistic for the tracking link and moves to the set App, Web, or Fallback.

When the tracking link is clicked, call click function.

In click function, deeplink and fallback are backup links used when there is no Internet connection.

(All of these are optional parameters.)

Deeplink parameters are only available in Custom URL Scheme format.

Impression

impression function +1 impression statistic for the 'tracking link'.

When the tracking link is displayed on the UI, call impression function.

If you are using custom domain, you cannot use tracking link using custom short ID.

example: http://deeplink.ab180.co/custom -> Unavailable

example: http://deeplink.ab180.co/a3b1c2 -> Available

example: https://abr.ge/a3b1c2 -> Available

Installed app lists

You can collect the list of installed apps on your customer's device.

AirBridge.setInstalledAppEnable(true); // Installed app lists option On

Airbridge.init();
AirBridge.setInstalledAppEnable(false); // Installed app lists option Off

Airbridge.init();

The default value for the list of installed apps in the Airbridge Android SDK is false.

User carrier name collection

You can collect the name of the user's carrier.

Add the following permissions to the app / src / main / AndroidManifest.xml file.

...
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
...

This setting increases the accuracy of cross-platform user matching.

Settings

Session duration

You can set the session duration for your app by calling the following method:

The duration of the session is in seconds and must be greater than 0 and less than or equal to 604800 (7 days).

AirBridge.setCustomSessionTimeOut(300);
Airbridge.init();

The session duration is by default 300 seconds (5 minutes).

Disable hashing of user information

The user's email and phone information is by default transmitted in a hashed format (SHA256).

If you do not want to hash the information, you can change the setting using the following method.

// Unhash User Information
AirBridge.getTracker().setIsUserInfoHashed(false);

// Hash User Information
Airbridge.getTracker().setIsUserInfoHashed(true);

Classification In-App event

The Airbridge dashboard displays statistics by separating events through Category, Action, and Label.

Category is the name of the event.

Action is subclass 1 of the event.

Label is subclass 2 of the event.

All in-app events can modify actions and labels.

Custom in-app events category can be changed but default in-app events category cannot be changed.

Code Example

SignUpEvent signUpEvent1 = new SignUpEvent()
        .setAction("Seoul")
        .setLabel("30s");

SignUpEvent signUpEvent2 = new SignUpEvent()
        .setAction("Seoul")
        .setLabel("40s");

SignUpEvent signUpEvent3 = new SignUpEvent()
        .setAction("Busan")
        .setLabel("30s");

PurchaseEvent purchaseEvent1 = new PurchaseEvent()
        .setAction("product A")
        .setLabel("option B");

PurchaseEvent purchaseEvent2 = new PurchaseEvent()
        .setAction("product A")
        .setLabel("option C");

GoalEvent subscribeEvent1 = new GoalEvent("subscribe")
        .setAction("normal");

GoalEvent subscribeEvent2 = new GoalEvent("subscribe")
        .setAction("preminum");

for(int i=0; i<10; i++) {
    AirBridge.getTracker().sendEvent(signUpEvent1);
}

for(int i=0; i<20; i++) {
    AirBridge.getTracker().sendEvent(signUpEvent2);
}

for(int i=0; i<15; i++) {
    AirBridge.getTracker().sendEvent(signUpEvent3);
}

for(int i=0; i<8; i++) {
    AirBridge.getTracker().sendEvent(purchaseEvent1);
}

for(int i=0; i<7; i++) {
    AirBridge.getTracker().sendEvent(purchaseEvent2);
}

for(int i=0; i<10; i++) {
    AirBridge.getTracker().sendEvent(subscribeEvent1);
}

for(int i=0; i<5; i++) {
    AirBridge.getTracker().sendEvent(subscribeEvent2);
}
val signUpEvent1 = new SignUpEvent()
        .setAction("Seoul")
        .setLabel("30s")

val signUpEvent2 = new SignUpEvent()
        .setAction("Seoul")
        .setLabel("40s")

val signUpEvent3 = new SignUpEvent()
        .setAction("Busan")
        .setLabel("30s")

val purchaseEvent1 = new PurchaseEvent()
        .setAction("product A")
        .setLabel("option B")

val purchaseEvent2 = new PurchaseEvent()
        .setAction("product A")
        .setLabel("option C")

val subscribeEvent1 = new GoalEvent("subscribe")
        .setAction("normal")

val subscribeEvent2 = new GoalEvent("subscribe")
        .setAction("preminum")

for(i in 1..10) {
    AirBridge.getTracker().sendEvent(signUpEvent1)
}

for(i in 1..20) {
    AirBridge.getTracker().sendEvent(signUpEvent2)
}

for(i in 1..15) {
    AirBridge.getTracker().sendEvent(signUpEvent3)
}

for(i in 1..8) {
    AirBridge.getTracker().sendEvent(purchaseEvent1)
}

for(i in 1..7) {
    AirBridge.getTracker().sendEvent(purchaseEvent2)
}

for(i in 1..10) {
    AirBridge.getTracker().sendEvent(subscribeEvent1)
}

for(i in 1..5) {
    AirBridge.getTracker().sendEvent(subscribeEvent2)
}

You can view each event statistic by Category in the Airbridge dashboard.

You can also see statistics separated by Action and Category.

As a result, you can view the following results on the dash board.

Category

Action

Label

Count

Sign up

Seoul

30s

10

Sign up

Seoul

40s

20

Sign up

Busan

30s

15

Payments

product A

option B

8

Payments

product A

option C

7

Subscribe

normal

10

Subscribe

premium

5

Log Monitoring

If you need to check the debugging log, add the following code to the onCreate method of your application's Application class:

AirBridge.setDebugMode(true);

Advanced - Web App

When Web App case, You can send in-app events as follows.

Send event from native (option 1)

On web, when android app, call native function and call Airbridge Android SDK to send Mobile Event.

On web, when browser, call Airbridge Web SDK to send Web Event.

Example code - Javascript

if (check Android app) {
    // When android app, send event with Airbridge Android SDK
    AirbridgeNative.goal('category')
} else {
    // When browser, send event with Airbridge Web SDK
    airbridge.events.send('category', {});
}

Example code - JavascriptInterface

ublic class AirbridgeInterface {
    @JavascriptInterface
    public void goal(String category) {
        GoalEvent event = new GoalEvent(category);
        AirBridge.getTracker().sendEvent(event);
    }
}

...
webView.addJavascriptInterface(new AirbridgeInterface(), "AirbridgeNative");
class AirbridgeInterface {
    @JavascriptInterface
    fun goal(category: String) {
        val event = GoalEvent(category)
        AirBridge.getTracker().sendEvent(event)
    }
}

...
webView.addJavascriptInterface(AirbridgeInterface(), "AirbridgeNative");

Send event from web (option 2)

On web, when android app, init Airbridge Android SDK with mobileApp to send Mobile Event.

On web, when browser, init Airbridge Web SDK to send Web Event.

Example code - Javascript

(function(a_,i_,r_,_b,_r,_i,_d,_g,_e){if(!a_[_b]||!a_[_b].queue){_g=i_.getElementsByTagName(r_)[0];a_[_b]={queue:[]};_d={};for(_i=0;_i<_r.length;_d={$jscomp$loop$prop$m$2:_d.$jscomp$loop$prop$m$2},_i++)_d.$jscomp$loop$prop$m$2=_r[_i],~_d.$jscomp$loop$prop$m$2.indexOf(".")&&(_e=_d.$jscomp$loop$prop$m$2.split(".")[0],a_[_b][_e]=a_[_b][_e]||{},a_[_b][_e][_d.$jscomp$loop$prop$m$2.split(".")[1]]=function(_d){return function(){a_[_b].queue.push([_d.$jscomp$loop$prop$m$2,arguments])}}(_d)),a_[_b][_d.$jscomp$loop$prop$m$2]=function(_d){return function(){a_[_b].queue.push([_d.$jscomp$loop$prop$m$2,arguments])}}(_d);_d=i_.createElement(r_);_d.async=1;_d.src="//static.airbridge.io/sdk/latest/airbridge.min.js";_g.parentNode.insertBefore(_d,_g)}})(window,document,"script","airbridge","init setBanner setDownload setDeeplinks sendSMS sendWeb setUserAgent setUserAlias addUserAlias setMobileAppData setUserId setUserEmail setUserPhone setUserAttributes setDeviceIFV setDeviceIFA setDeviceGAID events.send events.signIn events.signUp events.signOut events.purchased events.addedToCart events.productDetailsViewEvent events.homeViewEvent events.productListViewEvent events.searchResultViewEvent".split(" "));

var deviceUUID = undefined;
var packageName = undefined;
var isLimitAdTracking = undefined;
var appVersion = undefined;
var ifa = undefined;
var ifv = undefined;
var gaid = undefined;
    
try {
    deviceUUID = window.AirbridgeDeviceInfo.getDeviceUUID();
    packageName = window.AirbridgeDeviceInfo.getPackageName();
    isLimitAdTracking = window.AirbridgeDeviceInfo.isLimitAdTracking();
    appVersion = window.AirbridgeDeviceInfo.getAppVersion();
} catch {}

try {
    ifa = window.AirbridgeDeviceInfo.getIFA();
    ifv = window.AirbridgeDeviceInfo.getIFV();
} catch {}

try {
    gaid = window.AirbridgeDeviceInfo.getGAID();
} catch {}
    
if (typeof deviceUUID === 'string'
    && typeof packageName === 'string'
    && typeof isLimitAdTracking === 'boolean'
    && typeof appVersion === 'string'
    && typeof ifa === 'string'
    && typeof ifv === 'string')
{
    // when ios app
    airbridge.init({
        app: 'APP_NAME',
        webToken: 'WEB_TOKEN',
        mobileApp: {
            deviceUUID: deviceUUID,
            packageName: packageName,
            limitAdTracking: isLimitAdTracking,
            appVersion: appVersion,
            ifa: ifa,
            ifv: ifv,
        }
    });
} else if (typeof deviceUUID === 'string' 
    && typeof packageName === 'string'
    && typeof isLimitAdTracking === 'boolean'
    && typeof appVersion === 'string'
    && typeof gaid === 'string') {
    // when android app
    airbridge.init({
        app: 'APP_NAME',
        webToken: 'WEB_TOKEN',
        mobileApp: {
            deviceUUID: deviceUUID,
            packageName: packageName,
            limitAdTracking: isLimitAdTracking,
            appVersion: appVersion,
            gaid: gaid,
        }
    });
} else {
    // when browser
    airbridge.init({
        app: 'APP_NAME',
        webToken: 'WEB_TOKEN'
    });
}
// when android app, send web event
// when browser, send mobile event
airbridge.events.send('category', {
    'label': 'label',
    'action': 'action',
    'value': 123.0,
    'customAttributes': {
        'custom1': 123,
        'custom2': 'abc'
    }
});

Example code - Activity

public class MainActivity extends Activity {

    WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        fetchDeviceInfo((deviceInfo) -> runOnUiThread(() -> startWebView(deviceInfo)));
    }

    void startWebView(DeviceInfo deviceInfo) {
        webView = findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setDomStorageEnabled(true);

        webView.addJavascriptInterface(new DeviceInfoInterface(deviceInfo), "AirbridgeDeviceInfo");

        webView.setWebChromeClient(new WebChromeClient());
        webView.setWebViewClient(new WebViewClient());

        webView.loadUrl("http://dev.blog.airbridge.io/websdk-web-app/");
    }

    class DeviceInfoInterface {

        DeviceInfo deviceInfo;

        public DeviceInfoInterface(DeviceInfo deviceInfo) {
            this.deviceInfo = deviceInfo;
        }

        @JavascriptInterface
        public String getDeviceUUID() {
            return deviceInfo.uuid;
        }

        @JavascriptInterface
        public String getPackageName() {
            return deviceInfo.packageName;
        }

        @JavascriptInterface
        public boolean isLimitAdTracking() {
            return deviceInfo.isLAT;
        }

        @JavascriptInterface
        public String getAppVersion() {
            return deviceInfo.appVersion;
        }
      
        @JavascriptInterface
        public String getGAID() {
            return deviceInfo.gaid;
        }
    }

    void fetchDeviceInfo(DeviceInfoFetchListener listener) {
        PackageInfo info = context.getPackageManager.getPackageInfo(context.packageName, 0);

        String packageName = getApplicationContext().getPackageName();
        String appVersion = info.versionName;
        AtomicReference<String> uuid = new AtomicReference<>(null);
        AtomicReference<Boolean> isLAT = new AtomicReference<>(null);
        AtomicReference<String> gaid = new AtomicReference<>(null);

        final Thread waitThread = new Thread(() -> {
            try { Thread.sleep(3000); }
            catch (InterruptedException ignored) {}

            if (uuid.get() != null && isLAT.get() != null && gaid.get() != null) {
                listener.onFetched(new DeviceInfo(packageName, appVersion, uuid.get(), isLAT.get(), gaid.get()));
            }
        });

        waitThread.start();
      
        final Thread fetchGAIDthread = new Thread(() -> {
            gaid.set( AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext()).getId());
            if (uuid.get() != null && isLAT.get() != null && gaid.get() != null) {
                waitThread.interrupt();
            }
        });
      
        fetchGAIDthread.start();

        AirBridge.getDeviceUUID(input -> {
            uuid.set(input);
            if (uuid.get() != null && isLAT.get() != null && gaid.get() != null) {
                waitThread.interrupt();
            }
        });

        AirBridge.isLimitADTracking(input -> {
            isLAT.set(input);
            if (uuid.get() != null && isLAT.get() != null && gaid.get() != null) {
                waitThread.interrupt();
            }
        });
    }

    interface DeviceInfoFetchListener {
        void onFetched(DeviceInfo deviceInfo);
    }

    class DeviceInfo {
        String packageName;
        String uuid;
        Boolean isLAT;
        String appVersion;
        String gaid;

        public DeviceInfo(String packageName, String appVersion, String uuid, Boolean isLAT, String gaid) {
            this.packageName = packageName;
            this.uuid = uuid;
            this.isLAT = isLAT;
            this.appVersion = appVersion;
            this.gaid = gaid;
        }
    }
}
class TempActivity : Activity() {

    var webView: WebView? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        fetchDeviceInfo { deviceInfo ->
            runOnUiThread { startWebView(deviceInfo) }
        }
    }

    fun startWebView(deviceInfo: DeviceInfo) {
        webView = findViewById(R.id.webView)
        webView?.settings?.javaScriptEnabled = true
        webView?.settings?.domStorageEnabled = true

        webView?.addJavascriptInterface(DeviceInfoInterface(deviceInfo), "AirbridgeDeviceInfo")

        webView?.webChromeClient = WebChromeClient()
        webView?.webViewClient = WebViewClient()

        webView?.loadUrl("https://...")

    }

    class DeviceInfoInterface(val deviceInfo: DeviceInfo) {
        @JavascriptInterface
        fun getDeviceUUID() : String {
            return deviceInfo.uuid
        }

        @JavascriptInterface
        fun getPackageName() : String {
            return deviceInfo.packageName
        }

        @JavascriptInterface
        fun isLimitAdTracking() : Boolean {
            return deviceInfo.isLAT
        }

        @JavascriptInterface
        fun getAppVersion() : String {
            return deviceInfo.appVersion
        }
      
        @JavascriptInterface
        fun getGAID() : String {
            return deviceInfo.gaid
        }
    }

    fun fetchDeviceInfo(callback: (DeviceInfo) -> Unit) {
        val info = context.packageManager.getPackageInfo(context.packageName, 0)

        val packageName: String = applicationContext.packageName
        var uuid: String? = null
        var isLAT: Boolean? = null
        var appVersion: String = info.versionName
        var gaid: String? = null

        val waitThread = Thread {
            try { Thread.sleep(3000) }
            catch (ignored: InterruptedException) {}

            if (uuid != null && isLAT != null && gaid != null) {
                callback(DeviceInfo(packageName, appVersion, uuid!!, isLAT!!, gaid!!))
            }
        }

        waitThread.start()
          
        val fetchGAIDThread = Thread {
            gaid = AdvertisingIdClient.getAdvertisingIdInfo(applicationContext)!!.id
            if (uuid != null && isLAT != null && gaid != null) {
                waitThread.interrupt()
            }
        }
      
        fetchGAIDThread.start()

        AirBridge.getDeviceUUID { input ->
            uuid = input
            if (uuid != null && isLAT != null && gaid != null) {
                waitThread.interrupt()
            }
        }

        AirBridge.isLimitADTracking { input ->
            isLAT = input
            if (uuid != null && isLAT != null && gaid != null) {
                waitThread.interrupt()
            }
        }
    }

    class DeviceInfo(val packageName: String,
                     val uuid: String,
                     val isLAT: Boolean,
                     val appVersion: String,
                     val gaid: String)
}

Advanced

SDK Direct Install

Airbridge SDK

sdk-android-1.7.5.aar : Download

Download the SDK file and apply it to your project.

Google Play Installreferrer Library

installreferrer-1.0.aar : Download

Download the Google Play Installreferrer library and apply it to your project.

The license for the Google Play Installreferrer Library is Apache 2.0

Setting user information manually

In addition to triggering an event, you can set user information manually.

If you apply it in the following way, all events will be recorded as being triggered by that user.

AirBridge.getTracker().setUserID("testID");
AirBridge.getTracker().setUserEmail("[email protected]");
AirBridge.getTracker().setUserPhone("000-0000-0000");
AirBridge.getTracker().addUserAlias("key", "value");
AirBridge.getTracker().addUserAttribute("key", "value");
AirBridge.getTracker().setUserID("testID")
AirBridge.getTracker().setUserEmail("[email protected]")
AirBridge.getTracker().setUserPhone("000-0000-0000")
AirBridge.getTracker().addUserAlias("key", "value")
AirBridge.getTracker().addUserAttribute("key", "value")

The number of User Attribute size is up to 100

User Attribute key length is up to 128

User Attribute key should satisfy ^[a-z][a-z0-9_]*$ regular expression

User Attribute value should be primitive type
If User Attribute value is string, the value length is 1024

The number of User Alias is up to 10.

User Alias key length is up to 128.

User Alias value length is up to 128.

The User Alias key must satisfy the regular expression ^[a-z_][a-z0-9_]*$.

User alias and attributes information are not change when 'SignInEvent' and 'SignUpEvent' events occur.

User alias and attributes information will remove when the 'SignOutEvent' event occurred.

Manual setting for device information

Enter additional device information.

HashMap<String, String> deviceAlias = new HashMap<String, String>();
deviceAlias.put("key", "value");

AirBridge.getTracker().setDeviceAlias(deviceAlias);
AirBridge.getTracker().addUserAlias("key", "value");
val deviceAlias = HashMap<String, String>()
deviceAlias["key"] = "value"

AirBridge.getTracker().setDeviceAlias(deviceAlias);
AirBridge.getTracker().addUserAlias("key", "value");

Maximum count of Device-Alias is 10.

Maximum length of Device-Alias's key is 128.

Maximum length of Device-Alias's value is 128.

Device-Alias's key must meet [a-z_][a-z0-9_]* condition.

In-App Event Occurred in WebView

If you use WebView, you can send in-app events through Webview's Javascript Interface function.

public class MyWebAppInterface {
    Context mContext;

    MyWebAppInterface(Context context) {
        mContext = context;
    }

    /**
     * Sends goal event.
     */
    @JavascriptInterface
    public void goal(int value) {
        // TODO: Send event what you want
        GoalEvent event = new GoalEvent("my-category")
                .setAction(“my-action”);            
                .setValue(value);            
        AirBridge.getTracker().sendEvent(event);
    }
}

...
webView.addJavascriptInterface(new MyWebAppInterface(this), "myAndroid");
class MyWebAppInterface constructor(internal var mContext: Context){
    /**
    * Sends goal event.
    */
    @JavascriptInterface
    fun goal(value: Int) {
        // TODO: Send event what you want
         val event = GoalEvent("my-category")
                .setAction("my-action")
                .setValue(value)
        AirBridge.getTracker().sendEvent(event)
    }
}

...        
webView.addJavascriptInterface(MyWebAppInterface(this), "myAndroid")

The Javascript Interface allows you to call methods from your web app.

myAndroid.goal(1234);

Using another referrer tracking tool

Register the third party receiver with the name you want in the io.airbridge.DeferredLinkReceiver entry in the app/src/main/AndroidManifest.xml file.

<receiver android:name="io.airbridge.DeferredLinkReceiver" android:exported="true">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
    <!-- For GA Campaign Receiver -->
    <meta-data android:name="GAReceiver" android:value="com.google.android.gms.analytics.CampaignTrackingReceiver"/>
    <!-- For Custom Receiver -->
    <meta-data android:name="CustomReceiver1" android:value="io.airbridge.test.TPReceiver"/>
</receiver>

Exclude certain screens from tracking

Normally, Airbridge automatically tracks activities for statistical analytics.
But some non-generic activities can bring unintended statistical results.

For example, if the app offers a lock screen function, Airbridge will count user unlocks as an event action.

To prevent such unintended statistical reporting, you can mark these activities with an annotation @DontTrack to make exceptions.

@DontTrack
class LockscreenActivity extends Activity { ... }
@DontTrack
class LockscreenActivity : Activity { ... }

Support Android 4.0 (API 14) or lower

Airbridge SDK automatically tracks app life cycles for installs and performance statistics.

However, for Android 4.0 (API Level 14) or lower, automatic tracking is not possible, preventing accurate tracking.

In such case, manual tracking is required to collect statistics.

To Turn Off Tracking on Automatic Life Cycle

Before calling AirBridge.init (initializing Airbridge), please call the following method to turn off an automatic tracking.

PageTracker.disableAutoLifecycleTracking();
AirBridge.init(this, ...);
PageTracker.disableAutoLifecycleTracking()
AirBridge.init(this, ...)

To Manually Call Life Cycle Handler in Activity

When handler is called manually in Base Activity, where all of in-app activities are inherited,

tracking is enabled to measure life cycles of in-app activities.

class BaseActivity extends Activity {
    @Override
    public void onCreate(Bundle savedState) {
        super.onCreate(savedState);
        AirBridge.getLifecycleTracker().onActivityCreated(this, savedState);
    }

    @Override
    public void onResume() {
        super.onResume();
        AirBridge.getLifecycleTracker().onActivityResumed(this);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        AirBridge.getLifecycleTracker().onActivityDestroyed(this);
    }
}
class BaseActivity : Activity() {
    override fun onCreate(savedState: Bundle?) {
        super.onCreate(savedState)
        AirBridge.getLifecycleTracker().onActivityCreated(this, savedState)
    }

    override fun onResume() {
        super.onResume()
        AirBridge.getLifecycleTracker().onActivityResumed(this)
    }

    override fun onDestroy() {
        super.onDestroy()
        AirBridge.getLifecycleTracker().onActivityDestroyed(this)
    }
}

Get UUID information

Gets the DeviceUUID

AirBridge.getDeviceUUID(new AirBridge.UUIDCallback() {
    @Override
    public void done(String uuid) {

    }
});
AirBridge.getDeviceUUID{ uuid ->

}

Gets whether ADID is allowed

AirBridge.isLimitADTracking(new AirBridge.ADIDCallback() {
    @Override
    public void done(Boolean isLAT) {

    }
});
AirBridge.isLimitADTracking{ isLAT ->

}

Stop tracking (Opt-out)

You can stop sending events from the SDK.

AirBridge.setLimitUserTracking(true);
AirBridge.setLimitUserTracking(true);

true : Stop tracking

false : Tracking

SDK migration

If you are updating the SDK from a previous version, please check below.

before 1.6.14

1. Deferred Deeplink

Please call the DeepLink.registerDeepLinkCallback function before calling the AirBridge.init function.

DeepLink.registerDeferredLinkCallback(new DeepLink.Callback() {
    @Override
    public void TrackingLinkResponse(String URL, HashMap<String, String> param) {
        // do what you want to do
    }
});
AirBridge.init();
DeepLink.registerDeferredLinkCallback { URL, param ->
        // do what you want to do
}
AirBridge.init();

2. DeepLink

Please call the DeepLink.registerDeepLinkCallback function before calling the AirBridge.init function.

DeepLink.registerDeepLinkCallback(new DeepLink.Callback() {
    @Override
    public void TrackingLinkResponse(String URL, HashMap<String, String> param) {
        // do what you want to do
    }
});
AirBridge.init();
DeepLink.registerDeepLinkCallback { URL, param ->
        // do what you want to do
}
AirBridge.init();