Android Integration

Integration

To integrate the library, use the following code snippet:

import android.app.Application;
import com.bmtanalytics.sdk.tracking.BMT;
import com.bmtanalytics.sdk.tracking.Configuration;
import com.bmtanalytics.sdk.tracking.Configuration.UploadInterval;
import com.bmtanalytics.sdk.tracking.Event.Type;
import com.bmtanalytics.sdk.tracking.Event;
import com.bmtanalytics.sdk.tracking.ExtraData;
public class App extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        initBMT();
    }
    private void initBMT() {
        int BMT_API_KEY = 12;
        Configuration config = new Configuration.Builder()
        .setUploadInterval(UploadInterval.HALF_HOUR)
        .setGZIPEnabled(false)
        .setLogcatEnabled(true)
        .setUncaugthExceptionTracking(true)
        .build();
        BMT.init(this, BMT_API_KEY, config);   // with custom config
        // BMT.init(this, BMT_API_KEY); // with default config
        
        BMT.SessionData.addExtraData(
             new ExtraData("app", "BMT SDK Sample"));
        BMT.track(new Event(Type.OTHER, "Application loaded"));
    }
}    

Configuration

To control the working logic of Maxymizely tracking system, use these fields and methods:

Main configuration fields:

  • SiteId – an identifier of the resource needed to track
  • ConfigurationId – an identifier for user tracking
  • ExternalId – a unique user identifier (for example, an internal user ID in the database, email, login, Facebook ID, or any other information that helps identify a unique user)

Additional configuration methods:

BMT.SessionData.replaceExtraData(new ExtraData("attribute", attr))  

This method allows assigning a number of additional parameters to a user in the form of name-value.

You will need to grant sufficient permission rights in android.permission so that the tracking system could transfer the collected data to the server.

  • #INTERNET to upload the events to the tracking server
  • #ACCESS_NETWORK_STATE to check the status of network connections
  • #READ_PHONE_STATE to collect the information about a device

Here is a portion of the android manifest file:

<service
    android:name="com.bmtanalytics.sdk.api.UploadService"
    android:permission="android.permission.INTERNET" />
<receiver
    android:name="com.bmtanalytics.sdk.api.ConnectivityReceiver"
    android:permission="android.permission.ACCESS_NETWORK_STATE" >
    <intent-filter>
        <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
    </intent-filter>
</receiver>

Application

The basis for analysis is the process of tracking events that are taking place within an application. These events can be initiated by a user, as well as by interactive content within the window where the content is located.

For the system integrator, there are two levels of logged events:

  • System level
  • User level

The system level includes Type.ERROR event type, which logs information about errors. This event is called automatically by the system when an exception occurs. At the user level, all types of events are available.

An example of tracking installation:

BMT.track(new Event(Type.LOADPAGE, MyClass.class.getSimpleName()));  

Using the method BMT.track, the integrator implements checkpoints in the web resource functional system.

For accurate identification of the control events/checkpoints there is a set of configuration parameters:

  • Value – a checkpoint identifier (id html of the element, field name, etc.)
  • CustomAttribute1, CustomAttribute2, CustomAttribute3 – three additional attributes are set at the discretion of the user/developer

In the body of the procedure that handles the event, you need to specify:

BMT.track(new Event(Type.CLICK, "Login button clicked"));
BMT.track(new Event(Type.LOADPAGE, MyClass.class.getSimpleName()));  

Examples of events:

1. If you enter wrong credentials:

BMT.track(new Event(Type.LOGIN, "Login failed, incorrect credentials"));
BMT.SessionData.removeExtraDataByKey(Email);  

2. Or when you enter correct credentials:

BMT.track(new Event(Type.LOGIN, "Attempting to login"));
BMT.track(new Event(Type.VIEWELEMENT, "Progress is shown"));