Talk:Main Page

From docs.airpush.com
Jump to: navigation, search

Contents

Airpush Conversion Tracking (ACT)

Use ACT to measure the performance of your Airpush campaigns and maximize your ROI. You can track Android app downloads and mobile web conversions (e.g., leads, user registrations) to measure conversions, revenue per conversion, cost per conversion, and conversion rate percentage.

Airpush currently supports conversion tracking for:

  1. App downloads for Android
  2. WAP conversions (e.g., leads, user registrations)

This guide explains in detail how to integrate ACT so that you can track conversions.

To integrate ACT you will need the following:

  1. An active Android App / WAP page.
  2. An ad campaign in the Airpush Ad Network to promote your Android App / wap page.

How do I start Using ACT?

The conversion tracking process is very simple. Let us start with the obvious question. What do you want to track?

  1. Android App Install- Google Play Store
  2. Android App Install - 3rd Party Store or Self-hosted apps
  3. WAP Conversions

Android App Install- Google Play Store

Tracking your app conversions in Google Play Store is child’s play now. There are two ways to do this:

  1. Use ACT SDK
  2. Use App-2-Server Method
  3. .

Use ACT SDK

This is by far the simplest of all tracking methods. The implementation steps are:

  1. Include the following ACT SDK within your Android app and publish the updated app to the Google Play store. Download the SDK here.
    Click here for Instructions.
  2. Create a campaign promoting your Android app in Airpush.
  3. Append &referrer=guid%3D%guid% at the end of your Google Play URL. This is very important.
  4. Once your campaign starts getting clicks and your app is downloaded from Google Play store, the conversion numbers will start getting updated in the Airpush Campaigns Dashboard.

Creative URL should be like this:

 http://play.google.com/store/apps/details?id=<package_name>&referrer=guid%3D%guid%

Sample URL:

http://play.google.com/store/apps/details?id=com.test.app&referrer=guid%3D%guid%

ACT SDK installation instructions

Step 1 – Adding the JAR

For Eclipse projects:

If you are using ADT Plugin 18 or later then copy the appconversionsdk.jar to libs folder of your project and move to step 2.

Conversionscr.png

To verify whether it’s added to your project, expand the Android Dependencies.

Conversionscr1.png

Step 2 – Editing Your Manifest File

1: Copy and paste the following XML just before the closing </application> tag:

<receiver android:name="com.track.conversion.TrackingReceiver" android:exported="true" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>

2: Add following permissions in Manifest:

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

Use App-2-Server Method

This is a slightly complicated method. However, if you aren’t comfortable adding our ACT SDK to your app, you can use this method:

  1. You will have to add some code snippets to your Android App. The main files that need to be modified are BroadcastReceiver and Manifest file. Once the code has been added, update your app in the Google Play store. Click here for Instructions.
  2. Create a campaign promoting your Android app in Airpush
  3. Append &referrer=guid%3D%guid% at the end of your Google Play URL. This is very important.
  4. Once your campaign starts getting clicks and your app is downloaded from Google Play store, the conversion numbers will start getting updated in the Airpush Campaigns Dashboard.
App-2-Server installation Code for Android App Conversion Tracking

Step 1 – Add code in your BroadcastReceiver file

@Override
	public void onReceive(Context context, Intent intent) {
		try {
			if (intent.getAction().equals("com.android.vending.INSTALL_REFERRER")) {
				Bundle extras = intent.getExtras();
				String referrerString = extras.getString("referrer");
				if (referrerString != null && !referrerString.equals("")&& referrerString.contains("guid")) {
					Map<String, String> referralParams = new HashMap<String, String>();
					referrerString = URLDecoder.decode(referrerString, "UTF-8");
					String[] params = referrerString.split("&");
					for (String param : params) {
						String[] pair = param.split("=");
						referralParams.put(pair[0], pair[1]);
					}
					String guid = referralParams.get("guid");
					if (guid != null && !guid.equals(""))
						sendData(context, guid);
				} else
					Log.i("TrackingReceiver", "Referrer is null.");
			}
		} catch (Exception e) {
			Log.e("TrackingReceiver", "Error: " + e.getMessage());
		}

	}

	// check the internet connection
	private static boolean isConnected(Context context) {
		try {
		ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
			if (connectivityManager != null
					&& (connectivityManager.getActiveNetworkInfo()
							.isConnected())) {
				return true;
			} else {
				return false;
			}
		} catch (Exception exception) {
			Log.e("TrackingReceiver", "Internet connection not available");
			return false;
		}

	}

	// send data to api.
	private static void sendData(Context context, String guid) {
		final List<NameValuePair> list = new ArrayList<NameValuePair>();
		list.add(new BasicNameValuePair("guid", guid));
		list.add(new BasicNameValuePair("sdkVersion", "1.1"));
		Log.i("TrackingReceiver", "Values: " + list);
		if (!isConnected(context))
			return;
		Thread thread = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					HttpClient httpclient = new DefaultHttpClient();
					HttpPost httppost = new HttpPost("https://api.airpush.com/track/");
					httppost.setEntity(new UrlEncodedFormEntity(list));
					BasicHttpParams basicHttpParams = new BasicHttpParams();
					httppost.setParams(basicHttpParams);
					HttpConnectionParams.setConnectionTimeout(basicHttpParams, 15000);
					HttpConnectionParams.setSoTimeout(basicHttpParams, 10000);
					HttpResponse response = httpclient.execute(httppost);
					int code = response == null ? 0 : response.getStatusLine().getStatusCode();
					Log.i("TrackingReceiver", "Status code: " + code);
					if (code == 200) {
						String string = EntityUtils.toString(response.getEntity());
						Log.i("TrackingReceiver", "Response: " + string);
					}
				} catch (UnsupportedEncodingException e) {
					Log.e("TrackingReceiver", "UnsupportedEncodingException: "+ e.getMessage());
				} catch (Exception e) {
					Log.e("TrackingReceiver", "Exception: " + e.getMessage());
				}

			}
		});
		thread.start();
	}
Step 2 – Editing Your Manifest File

1: Add the below intent filter in your receiver:

<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>

Example:

<receiver android:name="<<Receiver file Name>" android:exported="true" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>

2: Add Following Permissions in Manifest:

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

Android App Install - 3rd Party Store or Self-hosted apps

If you would like to track conversions of your app that is hosted in other markets like Amazon, you will have to follow the below process.

  1. Create a campaign promoting your Android app in Airpush. Note down your Campaign ID and Creative ID.
  2. Enable your Android App to transmit conversion event data to Airpush API servers. Required data includes Campaign ID, Creative ID and md5 encrypted IMEI. Configure and integrate the conversion API code.
  3. Configure the conversion API code as follows. Replace placeholder values (i.e., , etc) with actual values.
     http://api.airpush.com/track/app/?campaignid=< CAMPAIGN ID >&creativeid=< CREATIVE ID >&IMEI=< MD5 ENCRYPTED IMEI > 
    ( Click Here to know how to collect IMEI)
  4. Call the conversion API immediately after the app installs. It can be a simple HTTP call. An example API URL is
    http://api.airpush.com/track/app/?campaignid=1000&creativeid=100&IMEI=abcdef1234567890 
How to Get MD5 Encrypted IMEI

When you are using ACT to track installs from 3rd party marketplaces like Amazon, you need to include the below code in your Android app, so that the IMEI is collected in MD5 encrypted format. Do note that this method requires READ_PHONE_STATE permission.

	// this method requires READ_PHONE_STATE permission.
	static String getIMEIinMd5(Context context) {
		try {
			String imeinumber = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
                        if (imeinumber == null || imeinumber.equals("")) {
				Class<?> c = Class.forName("android.os.SystemProperties");
				Method get = c.getMethod("get", String.class);
				imeinumber = (String) get.invoke(c, "ro.serialno");
			}
			MessageDigest mdEnc;
			mdEnc = MessageDigest.getInstance("MD5");
			mdEnc.update(imeinumber.getBytes(), 0, imeinumber.length());
			String imei = new BigInteger(1, mdEnc.digest()).toString(16); // Encrypted
			return imei;
		} catch (NoSuchAlgorithmException algorithmException) {
			algorithmException.printStackTrace();
		} catch (Exception ignored) {
			ignored.printStackTrace();
		}
		return "";
	}

WAP Conversions (mobile site conversions)

Website conversion tracking allows you to track a specific conversion point of your campaign's direct response, such as successful registrations,leads etc.

All conversions are recorded using a unique identifier called GUID, which is generated by Airpush on every click. Advertisers can receive this identifier on each click using macro %guid%. Advertisers can append the macro %guid% to their click through url.

Personal tools
Namespaces

Variants
Actions
Toolbox