Skip to content

PerformanceHorizonGroup/measurementkit-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

112 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Measurement Kit Android SDK (BETA)

Overview

Performance Horizon mobile measurement kit SDK allows advertisers to track installs and commissionable events and attribute to the original affiliate within a native application. By using the SDK in your app, in combination with the other components of Measurement Kit you can track a wide variety of in in-app events.

Measurement Kit consists of a tracking API, a smart banner SDK, and native SDK for iOS and Android. Building on top of Performance Horizon's API, Measurement Kit adds the additional facilities for interacting with native apps. Events and installs must be attributed to clicks either generated by the smart banner SDK, or by the mobile tracking API. Regular clicks (those from the domain prf.hn) are not tracked in all scenarios.

Integration with the mobile tracking API or the smart banner SDK is required for SDK install and event tracking.

This document describes installation and basic use of the mobile measurement kit SDK on the iOS platform.

Note on conversion display

Events and installs are tracked as conversions within the Performance Horizon Enterprise platform. At present, the conversions generated by MMK are of a type that is hidden within the standard interface. If you wish to view your events and installs, a conversion report can be generated by adding the conversion_meta_type=13 parameter to the conversion report, eg:

https://api.performancehorizon.com/reporting/report_advertiser/campaign/1011l45/conversion.json?start_date=2016-11-16+00%3A00%3A00&end_date=2016-12-16+00%3A00%3A00&meta_type%5Bclicks%5D=13&meta_type%5Bconversions%5D=13

Implementation

Installation

If you're using android studio, mobile tracking can be added to your gradle build as follows.

To your project build.gradle, ensure that the jcenter repository is available, as follows.

buildscript {
		repositories {
    		jcenter()
		}

		dependencies {
    		classpath 'com.android.tools.build:gradle:2.2.3'
		}
}

To your app module, add the following.

dependencies {
    /*
    *
    * All other dependencies....
    */
    compile 'com.performancehorizon.android:measurementkit:0.4.1'
}

Proguard

If you use proguard to shrink release builds, you will need to add the following to your proguard rules.

-dontwarn okhttp3.**
-dontwarn okio.*

Initialisation

Import com.performancehorizon.measurementkit.* into your main Activity and initialise.

import com.performancehorizon.measurementkit.MeasurementService;

protected void onResume()
	{
    	super.onResume();

    	MeasurementService.sharedInstance().initialise(this.getApplicationContext(), this.getIntent(), "phg_advertiser_id", "phg_campaign_id");

	}

You will receive your unique Performance Horizon Advertiser ID and Campaign ID when you are registered within the PHG platform. It is important to note that an Advertiser account can have multiple campaigns.

Google Play Install Referrer

The Google Play Store offers a method for ensuring optimal tracking accuracy via its Google Install Referrer. Clicks with a destination of the google play store will have a unique mobile tracking identifier is appended to the referrer parameter.

On install of the App, you can enable the pass back of this referrer value through the :

<application>
    <receiver android:name="com.performancehorizon.measurementkit.ReferrerTracker" android:exported="true">
        <intent-filter>
             <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
</application>

The SDK will collect the referrer token from the google play store in this case, and ensure accurate attribution.

If the referrer field is already in use in the links provided to publishers, please ensure that any data in it is uri query encoded so that additional data can be appended for use by Measurement Kit. E.g. https://play.google.com/store/apps/details?id=com.performancehorizon.exactview&referrer=advertiserdata%3Dreferrerdata%3B

If you're already using a referrer tracker from another library (Google Analytics, for example), then you can use a composite referrer. Google Analytics provides an example as a custom referrer tracker: https://developers.google.com/analytics/solutions/testing-play-campaigns

Tracking Events

Within the Performance Horizon Enterprise web-interface, conversions represent an affiliate-led sale. In MMK, we use a conversion to represent an in-app event. Events can be used to record in-app purchase, or commissionable user actions. An example would be an affiliate-led user registration, or crediting an account with funds. Install conversions are automatically generated where an affiliate link leads to an app install.

Event

The most basic form of event has no value associated with it. (Perhaps an in-app action on which you're not looking to reward affiliates.)

The category parameter is used to set the product conversions.

Event event = new Event("registration-initiated");
MeasurementService.sharedInstance().trackEvent(event);

Sale

If an event has a value you'd like to track, sales can be associated with an event as follows.

The currency parameter is a ISO 4217 currency code. (eg, USD, GBP)

Event event = new Event(new Sale("premium upgrade", new BigDecimal(34.5)), "GBP");
MeasurementService.sharedInstance().trackEvent(event);

FAQs

Testing

MeasurementKit checks for affiliate activity on first launch. If there's no prior activity, it will be disabled for future launches. If you're testing an integration, you may wish to reset it so that it will check for affiliate activity on each launch. You can do this with the clearTracking method on MeasurementService.

MeasurementService.sharedInstance().clearTracking(this);
MeasurementService.sharedInstance().initialise(this.getApplicationContext(), this.getIntent(), "phg_advertiser_id", "phg_campaign_id")

URL Scheme configuration

In order to be opened via the appropriate intent, a app woulrd commonly register a splash activity with an Intent filter as follows. (This example uses a custom scheme)

<intent-filter>
   <data android:scheme="exactview" android:host="open" />
   <action android:name="android.intent.action.VIEW" />
   <category android:name="android.intent.category.DEFAULT" />
   <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

Advertising Identifier

The advertising identifier from google play services is captured if that library is available on the device. It is used for attribution in some scenarios.

Debug Logging

Measurement Kit has a configuration option for extended debug logging that can be helpful in diagnosing integration issues. To enable, use the setDebugLogActive method on MeasurementServiceConfiguration.

    MeasurementServiceConfiguration configuration = new MeasurementServiceConfiguration();
    //enable debug logging.
configuration.setDebugLogActive(true);

    MeasurementService.sharedInstance(configuration).initialise(this, this.getIntent(), "1100l12", "1011l48");

About

SDK for performance marketing event tracking

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors