Getting Started with the Mobile Library for BlackBerry

An introduction and quick start guide to working with the Webtrends Mobile Library for BlackBerry development.

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

Welcome to the Mobile Application Library for BlackBerry. The Library provides a highly customizable integration with the BlackBerry OS version 4.5 and higher that allows you to send data to Webtrends every time a significant event occurs in your mobile application. You can start with our most basic implementation, which captures application events (starts, foregrounds, backgrounds) with no additional coding. With a little more work, you can insert calls to Webtrends event collection methods that allow you to track any event at any level of granularity.

Are you new to Webtrends?

  1. Add the Webtrends JAR file to your project.
    1. Open your development project.
    2. Right-click the project and click Properties.
    3. Click Java Build Path.
    4. Select the Libraries tab and click Add External JARs.
    5. Browse to WebtrendsRIMClientLib.jar.
    6. Select the Order and Export tab.
    7. Select the WebtrendsRIMClientLib.jar check box.
  2. Find the webtrends.xml file in your Webtrends Library downloaded files. In an editor of your choice, open it and change the following values:
    • wt_dc_app_category
    • wt_dc_app_name
    • wt_dc_app_publisher
    • wt_dc_app_version
    • wt_dc_dcsid
    • wt_dc_timezone (set this to the time zone of the Webtrends data source, expressed as an offset from GMT)
  3. Copy the webtrends.xml file into your source tree. At this point, you should identify a class in the same location and make a note of its full package and class name. You will need this information in Step 5.
  4. At the top of your .java file, insert the following import statement:
     import com.webtrends.mobile.analytics.rim.*;
  5. Insert the code shown in the example below in the first lines of your public static void main(String[] args), replacing com.webtrends.samples.helloworld.view.MyScreen with the package and class name you identified in Step 3.
    //Begin Webtrends initialization using Config XML code
       WebtrendsConfigurator.LoadConfigFile("com.webtrends.samples.helloworld.view.MyScreen", "webtrends.xml");
       WebtrendsDataCollector.getInstance().Initialize();
       //End Webtrends initialization using Config XML code
    In the example, MyScreen is the name of a class in the helloworld application package. If there are several classes in a package, any one class is OK. The class serves as a point of reference for finding the XML config file, so the actual class name is irrelevant.
  6. (Optional) If possible, extend your application to enable application state collection methods. Extending your application allows the Library to automatically send information about application starts, foregrounds, and backgrounds to Webtrends reporting. If you can't extend your application, see Application State Collection Methods for methods you can call.
    1. Determine whether your application can support automatic methods. To do this, find your application Main, for example public static void main(String[] args)). If the application can support the automatic tracking methods, you will find enterEventDispatcher in the Main. enterEventDispatcher is typically found in the public class entry point for your application and is contained in a public class. You should see either public class MyApplicationName extends Application or public class MyApplicationName extends UiApplication.
    2. Add the import for the Webtrends application extension as shown:
      import com.webtrends.mobile.rim.*;
    3. Change extends Application to extends WebtrendsApplication and extends UiApplication to extends WebtrendsUiApplication. Note that this command is case-sensitive, and that the "i" in "Ui" is lower case.
    4. (Optional) If you want to track application exits, manually add a call to onApplicationTerminate. If you track starts, you probably want to track exits too. Application starts can be tracked automatically, but application exits must be done manually.
    You'll begin sending data to Webtrends as soon as your application is built and running.
  7. Make sure your application has the correct permissions to use the Webtrends Library.
  8. You can compile your application and start tracking right away. For advanced analytics capability, use the Event Collection methods to instrument your application.