Mobile Apps Conversion Tracking

Conversion Tracking for iOS

AdWords Conversion Tracking for apps allows you to measure the effectiveness of your AdWords campaigns. Once you've integrated conversion tracking, you can log into Google AdWords to see important metrics like the number of downloads of an app that were driven by a certain ad campaign.

In addition to tracking downloads, you can also choose to track other conversion events within your app, for example: the number of users who signed in to their account after downloading, or the number of users who completed your game-play tutorial.

There are two options for integrating conversion tracking:

  • The simplest option is to incorporate a small tracking SDK into your Xcode project. The SDK communicates conversions to Google AdWords. Instructions for this client-side integration can be found below.
  • For more advanced users, if you already use an app analytics package to track downloads and activity in your app, you can often use conversion tracking without integrating Google's SDK. Instead, you can set up a server-to-server conversion feed from your app analytics package to AdWords (refer to these instructions).

Incorporating the SDK

For the following instructions, a sample project named ConversionExample is used. When going through the steps, replace ConversionExample with your project's name.

  1. Download and unpack the SDK.

  2. Right click on your project folder in Xcode and select Add Files to "ConversionExample"...

  3. Select the unpacked SDK folder and click Add.

  4. The SDK library references the iOS AdSupport development framework which may not already be part of your project. To add this framework, open the Link Binary With Libraries dropdown under the Build Phases tab. Add the framework from the iOS SDK using the + button.

  5. Finally, you need to add -ObjC to the Other Linker Flags of your application target's build setting:

    1. In Xcode's project navigator, press the blue top-level project icon.
    2. Click on your target, then the Build Settings tab.
    3. Under Linking > Other Linker Flags, add -ObjC to both Debug and Release.

Adding the Snippet

  1. Define an iOS mobile app conversion in your AdWords account. You'll be given a snippet that looks like this

    [ACTConversionReporter reportWithConversionID:@"your id here" label:@"your label here" value:@"your value here" isRepeatable:NO];
    

  2. To track downloads of your app, add the snippet that was provided in your AdWords account to the application:didFinishLaunchingWithOptions: method, found in your app's AppDelegate.

    // ConversionExampleAppDelegate.m
    
    #import "ConversionExampleAppDelegate.h"
    #import "ACTReporter.h"
    
    @implementation ConversionExampleAppDelegate
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
        [ACTConversionReporter reportWithConversionID:@"0123456789" label:@"abCDEFG12hIJk3Lm4nO" value:@"0.99" isRepeatable:NO];
        return YES;
    }
    
    @end
    

    Make sure to add the bold lines to your own AppDelegate, using your own snippet in place of the example.

    reportWithConversionID: takes 4 arguments that have been pre-filled for you in the snippet that is provided in your AdWords account:

    • an ID that identifies your conversion
    • an alphanumeric label that identifies your conversion
    • the value of your conversion (must be specified in the currency of your AdWords account)
    • a boolean to indicate whether the conversion should fire only once or should fire multiple times. We pre-populate the appropriate value for you and strongly recommend leaving the default value unchanged.

Tracking events beyond the download

It's also possible to track other events in your app, beyond the download.

Events you track in your app might include things like whether a user completes a gameplay tutorial after downloading your game, or whether a user signs in to an account after downloading.

To track these events, simply define additional conversions in your AdWords account, one for each event you'd like to track. Give each one a descriptive name. (AdWords allows you to define an arbitrary number of different conversions, and gives you a different label for each one)

You'll then include each code snippet in your app in the appropriate place to track the conversion.

Note that if your conversion has dynamic values (ex: some in-app purchases cost 99 cents while others cost 1.99) you can fill in the proper value into the 'value' parameter each time you report a conversion. This allows AdWords to show reporting of the value driven by your advertising.

Example: Tracking app upgrades

To track app upgrades, first define a new conversion in your AdWords account - call it something like "App upgrade".

Then take the conversion code snippet that was provided and put it inside a block of code that checks each time the app launches to see whether the app has just been upgraded to a newer version.

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#import "ACTReporter.h"

static NSString *const kApplicationVersionNumber = @"3.0.1";
static NSString *const kApplicationVersionNumberKey = @"my_application_version_number";

static NSString *const kConversionAppUpdateID = @"<conversion ID>";
static NSString *const kConversionAppUpdateLabel = @"<conversion label>";
static NSString *const kConversionAppUpdateValue = @"<conversion value>";

/// Splits the "." concatenated string of integers into an array of NSNumbers. Returns the array of
/// NSNumbers if all components can be converted to integers. Returns nil otherwise.
static NSArray *versionNumberArrayFromVersionNumberString(NSString *string) {
  NSArray *stringComponents = [string componentsSeparatedByString:@"."];
  NSMutableArray *numberComponents = [NSMutableArray arrayWithCapacity:[stringComponents count]];
  for (NSString *component in stringComponents) {
    NSScanner *scanner = [NSScanner scannerWithString:component];
    NSInteger integerValue = 0;
    if (![scanner scanInteger:&integerValue] || ![scanner isAtEnd]) {
      break;
    }
    NSNumber *value = @(integerValue);
    if (!value) {
      break;
    }
    [numberComponents addObject:value];
  }
  if ([numberComponents count] == [stringComponents count]) {
    return numberComponents;
  }
  return nil;
}

/// Returns YES if currentVersionNumberArray represents a newer version number than
/// previousVersionNumberArray.
static BOOL versionIsNewer(NSArray *previousVersionNumberArray,
                           NSArray *currentVersionNumberArray) {
  NSUInteger previousCount = [previousVersionNumberArray count];
  NSUInteger currentCount = [currentVersionNumberArray count];
  NSUInteger minCount = MIN(previousCount, currentCount);
  for (NSUInteger i = 0; i < minCount; ++i) {
    NSNumber *previousValue = [previousVersionNumberArray objectAtIndex:i];
    NSNumber *currentValue = [currentVersionNumberArray objectAtIndex:i];
    if ([previousValue compare:currentValue] == NSOrderedAscending) {
      return YES;
    }
    if ([previousValue compare:currentValue] == NSOrderedDescending) {
      return NO;
    }
  }
  if (currentCount > previousCount) {
    return YES;
  }
  return NO;
}

@interface MyAppDelegate : NSObject<UIApplicationDelegate>
@end

@implementation MyAppDelegate

- (void)reportConversionIfUpdated {
#if USE_ICLOUD_STORAGE
  NSUbiquitousKeyValueStore *storage = [NSUbiquitousKeyValueStore defaultStore];
#else
  NSUserDefaults *storage = [NSUserDefaults standardUserDefaults];
#endif

  NSString *previousVersionNumber = [storage stringForKey:kApplicationVersionNumberKey];
  NSArray *previousVersionNumberArray =
      versionNumberArrayFromVersionNumberString(previousVersionNumber);
  NSArray *currentVersionNumberArray =
      versionNumberArrayFromVersionNumberString(kApplicationVersionNumber);

  if (versionIsNewer(previousVersionNumberArray, currentVersionNumberArray)) {
    // Store the updated version number.
    [storage setObject:kApplicationVersionNumber forKey:kApplicationVersionNumberKey];

    // Report the upgrade conversion.
    [ACTConversionReporter reportWithConversionID:kConversionAppUpdateID
                                            label:kConversionAppUpdateLabel
                                            value:kConversionAppUpdateValue
                                     isRepeatable:YES];
  }
}

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // Configure application.

  // If required, report the update conversion.
  [self reportConversionIfUpdated];

  return YES;
}

@end

Confirming Setup

The first time you run your app after adding the conversion tracking snippet, you should see messages similar to the following logged to your console, indicating that your app is successfully tracking downloads:

ConversionExample[9412:c07] ACTConversionReporter: Sending ping with IDFA: http://www.googleadservices.com/pagead/conversion/998763253/?label=abCDEFG12hIJk3Lm4nO&value=0.99&muid=Hb3aor-9MHA7pTxkupe4Rw&bundleid=com.yourcompany.YourApp&appversion=1.0&osversion=6.1&sdkversion=ct-sdk-i-v1.2.0&timestamp=1363881621.780189.

ConversionExample[9412:c07] ACTConversionReporter: Ping successful.

The next time you run your app, these types of messages indicate the download tracking snippet already fired once (the first time the app was opened after being downloaded) and does not need to fire again:

ConversionExample[2618:c07] ACTConversionReporter: Already sent successful ping with IDFA and conversion label abCDEFG12hIJk3Lm4nO.

If you're tracking events in your app beyond the download, you should see messages logged for those events each time they occur. Unlike downloads, which are tracked only once per app install, other in-app events are tracked each time the event occurs. Pay special attention to the labels that were provided to you when verifying your setup (ex. abCDEFG12hIJk3Lm4nO in the example shown above). Each label corresponds to a different conversion event, so it's important not to mix them up. For example, abCDEFG12hIJk3Lm4nO might show up as "ColorDrips app download" in AdWords, but a different label, efGHIJK12hIJk3Lm4nO, might map to "ColorDrips in-app email sign-up". So it's worth checking that each event is firing the proper label.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.