Android Wear
Learn to install the Tealium SDK for Android Wear.
Requirements
- AndroidWear app with Tealium for Android
- Android (KitKat/4.4+ / API Level 20+ for Android Wear)
- Tealium Customer Data Hub account
API Reference
For the complete reference of classes and methods for Android Wear, see the com.tealium.wear
package in the Tealium SDK for Android API.
Sample App
To help familiarize yourself with the Tealium library, tracking methods, and best practice implementation, it is recommended to download the Tealium for AndroidWear sample app.
To abstract the Tealium implementation from the rest of your app, we recommend the use of the sample helper class. This gives you a single entry point from which to initialize and make tracking calls. It also allows you to update the code in your helper file and not in every single Java file.
Install
Install the Tealium library for your Android Wear app:
-
Download and install Tealium for Android Wear.
-
Add
tealium.mobile-5.x.x.aar
to your application’s dependencies.For non-wearable Android applications, no additional code is necessary.
-
Create a subclass of the
Application
class, and add theTealiumWear
’s initialization code in the app’sonCreate()
method, as shown in the following example:public class WearApp extends Application { // Instance name from main app public static final String TEALIUM_MAIN = "INSTANCE_NAME"; @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, as shown in the following example:// Main application initialization Tealium.createInstance("INSTANCE_NAME", config); // WearApp initialization public static final String TEALIUM_MAIN = "INSTANCE_NAME";
Tracking
Track Views
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
object, rather than a Map
:
The trackView()
method tracks screen views, as shown in the following example:
final DataMap data = new DataMap();
// ...
TealiumWear.getInstance(WearApp.TEALIUM_MAIN)
.trackView("SCREEN_NAME", data);
Track Events
The trackEvent()
method tracks non-view events, as shown in the following example:
final DataMap data = new DataMap();
// ...
TealiumWear.getInstance(WearApp.TEALIUM_MAIN)
.trackEvent("EVENT_NAME", data);
This page was last updated: January 7, 2023