Android Tagging

XtremePush has two methods for tagging activity in your app one for tagging page impressions and one for tagging any other events.

To tag events call the hitTag(String tag) method of the PushConnector class where that event occurs:

// You might for example want to tag a button press
    mPushConnector.hitTag("Checkout_Button_Pressed");

The hitTag method requires the PushConnector object you created when initialising XtremePush so if your app has a single base activity, you can create a public wrapper method to use it throughout your project , for example:

public void sendTag(String tag){
    mPushConnector.hitTag(tag);
}

To tag events that capture a value and grab the value, the hitTag method takes an extra argument for data hitTag(String tag, String data) for example:

// You might for example want to capture a form being filled out
mPushConnector.hitTag("form_1_field_1", "form_data");

Page Tagging for tracking Page Impressions

To tag page impressions call the hitImpression(String impression) method where your page loads:

mPushConnector.hitImpression("your_impression_name");

The tag used to record a page impression should uniquely identify a page and it should be set programatically in apps with content that updates dynamically from a feed, for example:

mPushConnector.hitImpression(yourPage.getPageTitle());

The hitImpression method requires the PushConnector object you created when initialising XtremePush so if your app has a single base activity, you can create a public wrapper method to use it throughout your project, for example:

public void sendImpression(String impression){
    mPushConnector.hitImpression(impression);
}

Batching of Tags

The default behaviour for Tags is that they are sent immediately, if you want to control how chatty your app is you can enable batching. 

To turn on batching you can call the following methods when initialising XtremePush in your Main Activity:

  • For batching of tags call setTagsBatchingEnabled(true) when initialising XtremePush:
    mPushConnector = new PushConnector.Builder("XTREME_PUSH_APP_KEY", "GOOGLE_PROJECT_NUMBER")
    .setTagsBatchingEnabled(true)
    .create(this);
  • For batching of impressions call setImpressionsBatchingEnabled(true) when initialising XtremePush:
    mPushConnector = new PushConnector.Builder("XTREME_PUSH_APP_KEY", "GOOGLE_PROJECT_NUMBER")
    .setImpressionsBatchingEnabled(true)
    .create(this);

Alternatively, batching for tags and impressions can be toggled during runtime as follows:

  • For batching of tags call mPushConnector.setTagsBatchingEnabled(true);
  • For batching of impressions call mPushConnector.setTagsBatchingEnabled(true);

With batching turned on tags or impressions will be cached when you call hitTag or hitImpression and released when you exit your app or when you call the sendTags or sendImpressions methods, as shown below:

To manually release tags:

mPushConnector.sendTags(); 

To manually release impressions:

mPushConnector.sendImpressions();

 

Have more questions? Submit a request

0 Comments

Article is closed for comments.