Getting Started with the Mobile Library for Windows Phone

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

Download the Mobile Application Analytics library for Windows Phone from the Developer Network.

Welcome to the Mobile Application Library for Windows Phone. The Library provides a highly customizable integration with the Windows Phone version 7 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, exit and terminate) 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 Library reference to your project.
    1. Using Microsoft Visual Studio, open your development project/solution.
    2. In Solution Explorer, identify the project to be instrumented.
    3. Right-click References and select Add Reference.
    4. Select the Browse tab, and browse to WebtrendsClientLib.dll.
    5. See the Webtrends Library reference in Solution Explorer.
  2. Add the Webtrends Library configuration file to your project.
    1. In Solution Explorer, identify the project to be instrumented.
    2. Right-click the project, select Add > Existing Item and browse to webtrends.xml.
    3. Right-click webtrends.xml and select Properties.
    4. In Properties > Advanced > Copy to Output Directory, select Copy always.
  3. Edit webtrends.xml and configure the Webtrends Library.
    1. Change the wt_dc_dcsid value to your DCSID, and change the wt_dc_timezone value to match the time zone of the Webtrends data source, expressed as an offset from GMT.

      The DCSID is the unique ID associated with a Webtrends data source. If you don't have a DCSID or you don't know what a data source is, contact your Webtrends administrator.

    2. Change the wt_dc_timezone value to match the time zone of the Webtrends data source.
    3. Change wt_dc_app_name to the name of your application.
    4. Change wt_dc_app_publisher to the application vendor or developer name.
    5. Change wt_dc_app_version to the version of your application.
    6. If you want to run your application in debug mode, set wt_dc_debug to true. wt_dc_debug logs so you can view them. To capture the logging messages, you must register an event handler in your App constructor. To send logging messages to the debugger, add the following event handler code to App.xaml.cs:
      using Webtrends.Mobile.Analytics;
                    
      // Constructor
      public App()
      {
             InitializeComponent();
      
             WTLogger.LogMessageEvent += (o, args) =>
             {
                    // write log message to debugger
                    Debug.WriteLine(args.Message);
             };
             .
             .
             .
      }
      Note: You should reset wt_dc_debug to false when you are ready to send data to include in Webtrends reports.
  4. At the top of your App.xaml.cs file, insert this using statement:
    using Webtrends.Mobile.Analytics;
  5. To automatically send information about application starts, stops, pauses, and resumes to Webtrends reporting, insert this code at the end of your Application object constructor (found in App.xaml.cs:
    /// <summary>
    /// Constructor for the Application object.
    /// </summary>
    public App()
    {
             .
             .
             .
             // Should be the last line of the constructor
             // Enable automatic event collection, including screen view events:
             //ApplicationStart, ApplicationTerminate, ApplicationForeground, ApplicationBackground, and ScreenView
             WTDataCollector.Instance.EnableAutomaticMethods(RootFrame);
    
             //Or
    
             // Enable automatic event collection, except for screen view events:
             //ApplicationStart, ApplicationTerminate, ApplicationForeground, ApplicationBackground
             WTDataCollector.Instance.EnableAutomaticMethods();
    
    }
    ...where RootFrame is the PhoneApplicationFrame object.
  6. Make sure your application has the correct permissions to use the Webtrends Library.
  7. You can compile your application and start tracking right away. For advanced analytics capability, use the Event Collection methods to instrument your application.