This library has been replaced by the version 5.x tealium-android repository. This version can still be used with Tealium services but no further development or bug fixes are planned.
The frameworks included allow the native tagging of a mobile application once and then configuration of third-party analytic services remotely through Tealium IQ; all without needing to recode and redeploy an app for every update to these services.
First time implementations should read the How Tealium Works wiki page for a brief overview of how Tealium's SDK differs from conventional analytic SDKs. For any additional information, consult the wiki home page.
The remainder of this document provides quick install instructions.
###Table of Contents###
- Requirements
- Android Studio Quick Start
- Eclipse Quick Start
- Run App
- Dispatch Verification
- What Next
- Contact Us
- Switching Between Full and Compact
###Requirements###
OR
- Android ADT Bundle with Eclipse
- NOTE: Written from the Eclipse perspective but compatible with any Android development environment.
- Minimum target Android Version: 9 / GINGERBREAD
####AS1. Add Tealium Library ####
AS1a. Add a libs folder to your Android Studio project's Application folder.
AS1b. Copy the desired Tealium library jar file into the new libs folder
AS1c. Add the jar files path to your Build.Gradle's dependencies
AS1d. Update Manifest.xml with the following use-permissions:
- android.permission.ACCESS_NETWORK_STATE
- android.permission.INTERNET
####AS2. Init and Track ####
AS2a. Add the following import statements to your Application or Activity Class:
package com.example.myapp;
import android.app.Application;
import com.tealium.library.Tealium;
import com.tealium.library.Tealium.Config;
import com.tealium.library.Tealium.LogLevel;
AS2b. Init the library in the same application class:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Must initialize after the super.onCreate() call.
Tealium.initialize(Config.create(this, "tealiummobile", "demo", "dev")
.setLibraryLogLevel(LogLevel.DEBUG));
// (!) Don't forget to replace "tealiummobile", "demo" and "dev" with your own account-profile-target settings before creating your production build.
}
}
This guide presumes you have already created an Android app using Eclipse. Follow the below steps to add Tealium's Full Library to it. Discussion on which version is ultimately best for you can be found in the What Next section.
####E1. Clone/Copy Library#### onto your dev machine by clicking on the Clone to Desktop or Download ZIP buttons on the main repo page.
####E2. Add To Project
E2a. Create a "libs" directory in your project root, if not already present.
E2b. From the android-library/TealiumFull folder, drag & drop the tealium.x.jar
file into your Eclipse project's Package Explorer window.
E2c. Click "Ok" in the resulting File Operation dialog box.
E2d. Add the following Permissions to your project:
- android.permission.INTERNET
- android.permission.ACCESS_NETWORK_STATE
Your project's AndroidManifest.xml's Permission's tab should now look similar to:
E2e. Import the library into your project's primary application class:
package com.example.myapp;
import android.app.Application;
import com.tealium.library.Tealium;
import com.tealium.library.Tealium.Config;
import com.tealium.library.Tealium.LogLevel;
E2f. Init the library in the same application class:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Must initialize after the super.onCreate() call.
Tealium.initialize(Config.create(this, "tealiummobile", "demo", "dev")
.setLibraryLogLevel(LogLevel.DEBUG));
// (!) Don't forget to replace "tealiummobile", "demo" and "dev" with your own account-profile-target settings before creating your production build.
}
}
Example of the required import and init statements:
MyApplication.java
package com.example.myapp;
import android.app.Application;
import com.tealium.library.Tealium;
// Subclass android.app.Application so that way Tealium
// will already be initialized for any Activity.
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// It is necessary to initialize after the super.onCreate() call.
Tealium.initialize(Tealium.Config.create(this, "tealiummobile", "demo", "dev")
.setLibraryLogLevel(Tealium.LogLevel.DEBUG));
// (!) Don't forget to replace "tealiummobile", "demo" and "dev" with your own account-profile-target settings before creating your production build.
}
}
E2g. Ensure the AndroidManifest.xml has been updated to use this Application subclass:
<!-- <manifest ... -->
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:name="com.example.myapp.MyApplication">
<!--
If "android:name" is not defined, Android will use the base
Application, and Tealium.initialize(...) will not be called.
-->
<!-- ... -->
</application>
<!-- ... </manifest> -->
E2h. Tealium.onResume(Activity) and Tealium.onPause(Activity) methods will need to be added to each of your activity classes if you minimum SDK < 14 (ICE CREAM SANDWICH).
Example:
MainActivity.java
package com.example.myapp;
import com.tealium.library.Tealium;
import android.os.Bundle;
import android.app.Activity;
public class MainActivity extends Activity implements View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected void onResume() {
super.onResume();
Tealium.onResume(this);
// COMPACT LIBRARY ONLY:
Tealium.track(this, null, null);
// The full library will pick up this view event automatically.
}
@Override
protected void onPause() {
super.onPause();
Tealium.onPause(this);
}
}
###Run Your app is now ready to compile and run. In the console output you should see a variation of:
Congratulations! You have successfully implemented the Tealium Full library into your project.
This output:
04-17 11:51:20.525: D/Tealium(2599): view : {
04-17 11:51:20.525: D/Tealium(2599): "object_class": "MainActivity"
04-17 11:51:20.525: D/Tealium(2599): "screen_title": "Tealium Example"
04-17 11:51:20.525: D/Tealium(2599): "tealium_id": "SEYco"
04-17 11:51:20.525: D/Tealium(2599): }
shows an abbreviation of all of the data gathered, use Tealium.Config.setLibraryLogLevel(LogLevel.VERBOSE)
to see all datasources available for mapping in Tealium's IQ Dashboard. The Library only actually sends those data sources and values that are mapped.
####Dispatch Verification
The two recommended methods for dispatch verification are:
- AudienceStream Live Events
- Vendor Dashboard
AudienceStream live events provides real time visualization of dispatched data if the Tealium DataCloud Tag has been added the same TIQ account-profile used to init the library:
An analytic vendor with real time processing, such as Google Analytics), can also be used to verify dispatches if the data sources have been properly mapped to the target vendors' variables.
Note: vendors without real-time processing may take up to several hours to update their reporting.
###Switching Between Full and Compact
Swapping the tealium.x.jar
with tealium.xc.jar
(or vice versa) is simple; just replace the undesired library in the libs/ directory with the desired library. Since the Full and Compact libraries have identical APIs; the swap will produce no errors.
Now that you've successfully integrated the library, you should now determine if the Compact or Full Library versions best fit your needs. Below are the key differences:
Compact | Full | |
---|---|---|
jar size | 102 KB | 177 KB |
Initialization time | ~ 0.01 sec | ~ 0.01 sec |
Memory Usage | ~ 604 KB | ~ 741 KB |
Non-UI AutoTracking | Yes | Yes |
UI Autotracking | No | Yes |
Mobile Companion | No | Yes |
Mobile AudienceStream Trace | No | Yes |
If continuing with the Compact version, add any needed additional tracking calls for events or view appearances.
Still can't decide? Browse through our wiki pages for more info, or check out our TealiumIQ Community
If you choose to ProGuard an app bundled with the Tealium Library; please be sure to start with the default configuration located at ${sdk.dir}/tools/proguard/proguard-android.txt
. The following rules will also need to be added to the default:
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}
-keep class com.tealium.library.* {
public <init>(...);
<methods>;
}
Questions or comments?
- Post code questions in the issues page.
- Contact your Tealium account manager
- Version 4.1.4
- Added setAcceptThirdPartyCookie API to Tealium.Config
- Removed Automatic lowercasing of data source Keys
- Version 4.1.3
- Added setAcceptCookie API to Tealium.Config
- Version 4.1.2
- Corrected a bug where passing a non-anticipated object in the Tealium.track(...) method failed to populate various data source keys
- Version 4.1.1
- Corrected
platform_version
andos_version
data sources - Bug fixes
- Version 4.1
- Added Support for TagBridge
- Added Android Studio compatible Sample Apps.
- Version 4.0
- Added Support for Mobile Publish Settings
- Removed Methods/Fields deprecated in Version 3.
- Version 3.1:
- Added UI-Autoracking Activity exlusion API
- Version 3.0:
If upgrading from a Library version earlier than 3.0 note that:
- void trackCustomEvent(String eventName, Map<String, String> variables)
- void trackItemClicked(String itemName)
- void trackItemClicked(String itemName, Map<String, String> variables)
- void trackScreenViewed(String viewName)
- void trackScreenViewed(String viewName, Map<String, String> variables)
are no longer available. Please also note that
boolean onResume(Activity)
is now
void onResume(Activity)
and
boolean onPause()
is now
void onPause(Activity)
Copyright (C) 2012-2015, Tealium Inc.