Archived‎ > ‎

Download Tracking - iOS

These instructions allow a publisher to send app unique-ids to Vdopia. This will allow Vdopia to provide conversion metrics for campaigns which include an app download component.
The methodology is that the app developer uses a web-service to report hashed unique-ids of devices where the app is installed. The developer can learn of the unique-ids in various ways, but in all cases, reporting to Vdopia happens through the same web-service. For example:

A) Developer adds code to their app to read the unique-id from the device, create a hash and report it to Vdopia.

B) Developer already has code to collect unique-ids from the app on their server. The developer implements a server-side service to call Vdopia with installed unique-ids.

Developer receives unique-ids where the app is installed through an analystics service (e.g. Flurry) and implements a server-side service to call Vdopia with installed unique-ids.

For all cases, the URL to invoke is:

1) DEVICE_ID - Device id where the install occured (can be the raw UDID or hashed)
2) APP_ID - Application id (iTunes App id or Android package name)
3) HASH_TYPE - Optional parameter (include only if the DEVICE_ID field is hashed). Supported types: 'md5' (16 character - uppercase), or 'none'

Example URLs:

A. Change app to report hashed unique-id to Vdopia.

i) Add this line to your appdelegate.m file’s applicationDidFinishLaunching: or applicationDidFinishLaunchingWithOptions: method:
[self performSelectorInBackground:@selector(reportAppOpenToVdopia) withObject:nil];

ii) add the following include file to your appdelegate.m file
#import <CommonCrypto/CommonDigest.h>

iii) Add these two function to appdelegate.m file

- (NSString *)getid {
  NSString *uniqueid=[UIDevice currentDevice].uniqueIdentifier;
    const char *value = [uniqueid UTF8String];
    unsigned char outputBuffer[CC_MD5_DIGEST_LENGTH];
    CC_MD5(value, strlen(value), outputBuffer);
    for(NSInteger count = 0; count < CC_MD5_DIGEST_LENGTH; count++){
      uniqueid=[uniqueid stringByAppendingFormat:@"%02x",outputBuffer[count]];
    uniqueid=[uniqueid uppercaseString];
  return uniqueid;

- (void)reportAppOpenToVdopia {
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES) objectAtIndex:0];

  NSFileManager *fileManager = [NSFileManager defaultManager];

  NSString * trkBase=@"";

  NSString *vdopiaAppOpenPath = [documentsDirectory stringByAppendingPathComponent:@"vdopia_app_open"];

  int val=0;
  NSURLResponse *response;
  NSError *error=nil;
  NSData *responseData=nil;
  if(![fileManager fileExistsAtPath:vdopiaAppOpenPath]) {
    NSString *vdopiatrkurl = [NSString stringWithFormat:trkBase,[self getid],[[NSBundle mainBundle] bundleIdentifier]];

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:vdopiatrkurl]];

    responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

  if(val==1 && (!error) && ([(NSHTTPURLResponse *)response statusCode] == 200) && ([responseData length] > 0)) {
    [fileManager createFileAtPath:vdopiaAppOpenPath contents:nil attributes:nil];

  [pool release];