Android SDK

The Webtrends SDK is a library for Android that enables easy integration with Webtrends Optimize. This guide will walk you through the initial setup process, from integrating the SDK with your project, to sending events to Webtrends.

Installing the SDK

Download the Mobile Application Analytics library for Android from the Developer Network.

The SDK is packaged into a ZIP file. Once extracted, you will find:

  • The compiled SDK (an Android AAR file)
  • A README.txt file describing the package
  • The Hybrid Guide for the SDK (Webtrends-HybridAppDevelopersGuide.pdf)
  • Webtrends-mobile-hybrid-lib.3.0.js (Javascript enabling Analytics features in hybrid apps)
  • Webtrends-mobile-lib.3.0.js (Webtrends Mobile Application Library)
  • A sample webtrends.xml file
  • A sample application that uses the SDK


    Import the SDK into Your Project

    Once you have an Android project, adding the SDK is simple. These instructions will be based on using Android Studio, but they may easily be adapted for use with Eclipse or any other Android IDE.

    1. Once the SDK is downloaded and extracted, open up your Android project.
    2. Select your project root, then choose Project Structure… from the File menu.
    3. Click the **+** sign on the top left to add a new module.
    4. Select Import .JAR/.AAR Package from the list of options and click Next.
    5. Browse to the extracted webtrends-sdk-release-xxx-lib.aar file. This filename will vary from version to version. Click Finish to import.
    6. With your main module (your application) selected, click the Dependencies tab.
    7. Click the **+** sign at the bottom to add a Module dependency to your application.
    8. Select the module that you just imported and click OK.


    Adding the webtrends.xml file to Your Project

    Create a new webtrends.xml file or import the included webtrends.xml file into your project’s resources (res/values/) directory. The webtrends.xml file contains required and optional configuration settings. The only required entries in this file are:

  • wt_opt_key_token: Your Webtrends Optimize™ key token
  • wt_opt_domain_id: Your Optimnize™ domain ID, also known as an account number
  • wt_opt_account_guid: Your Webtrends Account GUID. This is a 10-character alphanumeric string. Do not include the “.acct.webtrends.com” suffix.
  • wt_opt_project_locations: A comma-separated list of project locations. For this example, it will contain the project location that you define above in the Optimize™ application.
  • wt_opt_staging_mode: Set this to true if you have created Optimize™ tests in staging mode. This is commonly used while developing applications and Optimize™ tests. Once the application is ready for launch, remove this setting or set it to false and change the tests in Optimize™ to Active.
  • Open the file for editing and change the following values:


    1 <?xml version="1.0" encoding="utf-8"?>
    2 <resources>
    3  <string name="wt_opt_project_locations">COMMA_SEPARATED_LIST_OF_OPTIMIZE_PROJECT_LOCATIONS</string>
    4  <string name="wt_opt_domain_id">YOUR_DOMAIN_ID</string>
    5  <string name="wt_opt_key_token">YOUR_KEY_TOKEN</string>
    6  <string name="wt_opt_staging_mode">TRUE_OR_FALSE</string>
    7  <string name="wt_opt_account_guid">YOUR_ACCOUNT_GUID</string>
    8 </resources>

    Your project is now configured to use the Webtrends Mobile SDK.