Tealium for Android Wear

Tealium for Android Wear

by on ‎05-16-2016 10:58 AM - edited on ‎09-08-2017 09:42 AM by Community Manager (919 Views)

This guide shows how to add Tealium to your Android Wear app to track user activity. 

Table of Contents Placeholder

Requirements

Get the Code

The code for the Tealium Android Wear library can be found on Github in the same repository as Tealium for Android. You must download and install the library before proceeding.

The files specific to Android Wear can be found in tealium-android/Support/AndroidWear/.

Handheld

Add tealium.mobile-5.x.x.aar to your application's dependencies. No additional code is necessary.

Wearable

In the application's wear module add the tealium.wear-5.x.x.aar dependency. Subclass the Wear Application's subclass and add the TealumWear's initialization code in its onCreate function.

public class WearApp extends Application {

    public static final String TEALIUM_MAIN = "INSTANCE"; // Instance name from main app

    @Override
    public void onCreate() {
        super.onCreate();

        TealiumWear.createInstance(
                TEALIUM_MAIN,
                TealiumWear.Config.create(this)
                        .setLogLevel(Log.VERBOSE));
    }
}

The value of TEALIUM_MAIN must match the instance name used in the initialization of the main application. For example, if your main application is initialized with this line:

Tealium.createInstance("my_app", config);

You would change the line in the WearApp to this:

public static final String TEALIUM_MAIN = "my_app";

Tracking

Tracking on the wearable is similar to the handheld side. The only difference is in how to pass custom data to the tracking calls. The wearable side uses a DataMap() instead of a Map():

Tracking Views

java
final DataMap data = new DataMap();
// ...

TealiumWear.getInstance(WearApp.TEALIUM_MAIN)
    .trackView("someView", data);

Tracking Events

java
final DataMap data = new DataMap();
// ...

TealiumWear.getInstance(WearApp.TEALIUM_MAIN)
    .trackEvent("someEvent", data);

Samples & Documentation