Getting Started - Integrating the Android Tracking Library
    • 4 Minutes to read
    • Dark
      Light

    Getting Started - Integrating the Android Tracking Library

    • Dark
      Light

    Article summary

    This chapter provides instructions on how to set up your development environment before you can integrate tracking functions into your app.

    In the following, the integration of the tracking library is described using Android Studio and Gradle.

    If you are still using Eclipse, it is possible to integrate your application with Mapp Intelligence tracking library. Please contact your consultant or Account Manager for details regarding this topic.

    Adding a Dependency

    In your Android Studio project, first, add a new dependency:

    1
    2
    3
    4

    Dependencies {...
      implementation 'com.webtrekk.webtrekksdk:WebtrekkSDK:VERSION'
       
    }

    Our Android SDK library is hosted at the following distribution platform: Android Tracking Library. Here, you will always find the latest SDK version for Android. Please add the desired version by replacing "VERSION", for example, 4.7.3 in the dependency statement.

    Adapting the "manifest.xml"

    Now adapt the permissions in the Android "manifest.xml."

    Mandatory

    The following permissions are always needed, otherwise no requests can be transmitted.

    < uses - permission android: name = "android.permission.ACCESS_NETWORK_STATE" / >
    < uses - permission android: name = "android.permission.INTERNET" / >

    Optional

    If you want to track the user name or other profile information from the Play Store, such as the user’s email address, the following permissions also have to be added:

    < uses - permission android: name = "android.permission.READ_PROFILE" / >
    < uses - permission android: name = "android.permission.READ_CONTACTS" / >
    < uses - permission android: name = "android.permission.GET_ACCOUNTS" / >

    Element

    Description

    READ_PROFILE

    Is required for: First name, last name.

    READ_CONTACTS

    Is required for: email address.

    GET_ACCOUNTS


    Basic Configuration in Tag Integration

    The implementation of the app tracking is realized through Mapp Tag Integration. Please refer to the chapter Basic Implementation for details.

    Configuration File "webtrekk_config.xml"

    The "webtrekk_config.xml" file contains the required configuration that you have made as the basic configuration in Tag Integration (see step 3). To send tracking requests to your Mapp Intelligence account, you must integrate this XML file into your SDK.

    For this purpose, download this file as described here and then save this file in the resources folder of your Android module directory: "module/res/raw".

    In some cases you receive this configuration file initially from our support team; it is then preconfigured individually for you.

    Example "webtrekk_config.xml"

    <? xml version = "1.0" encoding = "UTF-8" ?>
    < webtrekkConfiguration >
       < version >44</ version >
       < trackId >123451234512345</ trackId >
       < trackDomain >https://q3.webtrekk.net</ trackDomain >
       < sampling >0</ sampling >
       < sendDelay >3</ sendDelay >
       < maxRequests >4000</ maxRequests >
       < resendOnStartEventTime >30</ resendOnStartEventTime >
       < autoTracked >false</ autoTracked >
       < autoTrackAppUpdate >true</ autoTrackAppUpdate >
       < autoTrackAdvertiserId >true</ autoTrackAdvertiserId >
       < autoTrackAppVersionName >true</ autoTrackAppVersionName >
       < autoTrackAppVersionCode >true</ autoTrackAppVersionCode >
       < autoTrackRequestUrlStoreSize >true</ autoTrackRequestUrlStoreSize >
       < autoTrackAppPreInstalled >true</ autoTrackAppPreInstalled >
       < autoTrackApiLevel >true</ autoTrackApiLevel >
       < autoTrackScreenOrientation >true</ autoTrackScreenOrientation >
       < autoTrackConnectionType >true</ autoTrackConnectionType >
       < autoTrackAdvertisementOptOut >true</ autoTrackAdvertisementOptOut >
       < autoTrackPlaystoreUsername >false</ autoTrackPlaystoreUsername >
       < autoTrackPlaystoreMail >false</ autoTrackPlaystoreMail >
       < enableRemoteConfiguration >true</ enableRemoteConfiguration >
       < trackingConfigurationUrl >https://d1r27qvpjiaqj3.cloudfront.net/1111111111111111/36818.xml</ trackingConfigurationUrl >
       < globalTrackingParameter >
         < parameter id = "INTERN_SEARCH" key = "AT1" />
         < pageParameter >
           < parameter id = "1" key = "TP1" />
           < parameter id = "2" >ConstParam1</ parameter >
         </ pageParameter >
         < pageCategories >
           < parameter id = "1" key = "PageCatKey" />
           < parameter id = "2" key = "TrainingNewParameterKey" />
         </ pageCategories >
       </ globalTrackingParameter >
       < screen >
         < classname type = "text" >com.webtrekk.webtrekksdk.training.MainActivity</ classname >
         < mappingname type = "text" >MainName</ mappingname >
         < autoTracked >false</ autoTracked >
       </ screen >
       < screen >
         < classname type = "text" >com.webtrekk.webtrekksdk.training.ComplexActivity</ classname >
         < mappingname type = "text" >CustomPage1</ mappingname >
         < autoTracked >false</ autoTracked >
       </ screen >
       < screen >
         < classname type = "text" >com.webtrekk.webtrekksdk.training.SimpleActivity</ classname >
         < mappingname type = "text" >SimpleName</ mappingname >
         < autoTracked >true</ autoTracked >
         < screenTrackingParameter >
           < pageParameter >
             < parameter id = "5" key = "TP1" />
             < parameter id = "1" key = "TP2" />
             < parameter id = "1" key = "AT2" />
           </ pageParameter >
           < ecomParameter >
             < parameter id = "1" key = "TP1" />
           </ ecomParameter >
         </ screenTrackingParameter >
       </ screen >
       < errorLogEnable >true</ errorLogEnable >
       < errorLogLevel >3</ errorLogLevel >
       < autoTrackAdClearId >true</ autoTrackAdClearId >
       < recommendations >
         < recommendation name = "complexReco" >https://reco.webtrekk.com/dmp/recos/v1/?accountId=238713152098253&placementId=39876</ recommendation >
       </ recommendations >
    </ webtrekkConfiguration >

    Please make sure that the parameter "enableRemoteConfiguration" in the XML file is set to TRUE. This is the only way for all other settings and changes made in Tag Integration to take effect.

    With these basic settings, the functionality of the SDK is now available to you. By enabling autotracking you have already implemented full activity tracking and are now sending initial requests to your Mapp Intelligence account.


    Was this article helpful?