App Install Tracking
As an advertiser, you can track how many installs of your application result from your advertising activity on Adfonic. To do so, you can either embed a short piece of code within your app, or integrate from your server if you're already collecting unique device identifiers from your users.
You will then be able to see the total number of installs, conversion percentage and cost per install in the advertiser dashboard and reporting section of the Adfonic site.
Contents |
Background
App install tracking is available for any iOS or Android application, provided you have access to the unique device identifier of each user installing the app, either on the client side (within the application itself) or from a server. In addition to the device identifier (usually called the UDID for iOS and Android Device ID) you will need to know the unique App Store ID assigned by Apple, or package name used for Android, for your application (or if you don't have this, your own unique identifier).
Because app install tracking relies on Adfonic knowing the device identifier, campaign creatives that require install tracking will only be shown within applications that provide this information, and will not be shown on mobile sites.
How to Enable App Install Tracking
The app install tracking option is on the Bid & Tracking page of a campaign. To enable the option, you need to:
1. Set your campaign to target only iOS or Android (but not both) in Audience > Device > Target by Device - screenshot
2. Make sure that at least 1 creative has an app store as its destination - screenshot
iPhone Client-Side Integration
To record app installs within your app itself, you'll need to add the following method to your code, adding in your own application ID.
If you don't yet have an application ID from the App Store, don't panic; you can use your own identifier, as long as you enter the same value while setting up your campaign creative(s).
In the code sample below, you need to change "appStoreID" to your own value.
-(void)adfonicInstallTracking {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *key = [NSString stringWithFormat:@"%@_AdfonicInstall",
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]];
if ([defaults boolForKey:key] == NO) {
NSString* url = [NSString stringWithFormat:@"http://tracker.adfonic.net/is/%@/%@",
@"appStoreID", [[UIDevice currentDevice] uniqueIdentifier]];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
NSURLResponse *urlResponse;
NSError *error;
[NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
int code = (urlResponse ? [(NSHTTPURLResponse *)urlResponse statusCode] : -1);
if (!error && (code == 200)) {
[defaults setBool:YES forKey:key];
}
}
[pool release];
}
Then, simply call the above method from your applicationDidFinishLaunching method on the application delegate, as shown below.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[self performSelectorInBackground:@selector(adfonicInstallTracking) withObject:nil];
}
Android Client-Side Integration
To record app installs within your app itself, you'll need to add the following method to your code. This method can be called from the onCreate method in the installed app. It will be called each time the app is launched. It only requires the permission: <uses-permission android:name="android.permission.INTERNET" />
private void trackInstall() {
final String INSTALL_TRACKED = "INSTALL_TRACKED";
final String PREFS_PACKAGE = "com.adfonic";
SharedPreferences prefs = getApplicationContext().getSharedPreferences(
PREFS_PACKAGE, 0);
String trackingPref = prefs.getString(INSTALL_TRACKED, null);
if (trackingPref == null) {
new Thread(new Runnable() {
@Override
public void run() {
String phoneId = Secure.getString(getApplicationContext()
.getContentResolver(), Secure.ANDROID_ID);
String pack = getApplicationContext().getPackageName();
HttpClient client = new DefaultHttpClient();
String url = String.format("http://tracker.adfonic.net/is/%s/%s",
pack, phoneId);
HttpGet request = new HttpGet(url);
HttpResponse response = null;
try {
response = client.execute(request);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (response != null && response.getStatusLine() != null
&& response.getStatusLine().getStatusCode() == 200) {
SharedPreferences.Editor editPrefs = getApplicationContext()
.getSharedPreferences(PREFS_PACKAGE, 0).edit();
editPrefs.putString(INSTALL_TRACKED,
Boolean.TRUE.toString());
editPrefs.commit();
}
}
}).start();
}
}
Server-Side Integration
You can also submit application install events from your server, provided you are collecting the UDID each time your app is installed and opened for the first time.
You need to submit both the application ID (unique for your application and matching the ID you entered when setting up your campaign) and the unique device identifier(s) of the user installing the app, to the following URL:
(For more information about the available device identifiers for iOS applications, please see this blog post.)
http://tracker.adfonic.net/is/[applicationID]?{d.odin-1|d.dpid|d.udid|d.android|d.openudid|d.hifa|d.ifa}=<device identifier>
Keep in mind that multiple values can be passed. E.g. d.dpid AND d.openudid.
| Parameter | Platform | Expected Input |
|---|---|---|
| d.udid | < iOS 6 | 40 hexadecimal characters |
| d.dpid | < iOS 6 or Android | 40 hexadecimal characters, the SHA-1 of the UDID or Secure.ANDROID_ID |
| d.android | Android | 16 hexadecimal characters, the Secure.ANDROID_ID |
| d.ifa | iOS >= 6 | 36 hexadecimal characters, the string representation of the Identifier for Advertisers, including hyphens |
| d.hifa | iOS >= 6 | 40 hexadecimal characters, the SHA-1 of the Identifier for Advertisers (as above) |
| d.openudid | Any | The OpenUDID value as specified at www.openudid.org |
| d.odin-1 | iOS or Android | The ODIN-1 value as specified at http://code.google.com/p/odinmobile/wiki/ODIN1 |
Deprecated - listed for older integrations
http://tracker.adfonic.net/is/[applicationID]/[UDID]
This should be a HTTP GET request.
The HTTP response code will be 200 if your request is successfully processed. You can also inspect the body of the response to check whether Adfonic is claiming responsibility for the particular UDID referenced. In this case the response will be:
success=1
If the user has installed the application through other means (for example, direct installation from the App Store or an advertisement from a different network) the request will still return code 200, but the response will indicate:
success=0
Unsuccessful install tracking events will not be recorded on your Adfonic dashboard.
error=Unknown+unique+identifier
This error parameter is for added information regarding the failed response. If you have install tracking enabled, but the campaign is not live, Adfonic will not have seen a click-through from the device. It will be an unknown unique identifier (Example: UDID).
AD-X
Should you be using AD-X to track your application installs and would like to use Adfonic for your campaign, you will need to download the following SDK and then contact Adfonic to enable your campaign : Adfonic_iOS_Non-UDID_SDK_adx.zip