Google Analytics Integrations by Daniel Waisberg

Google Analytics Integrations by Daniel Waisberg

Author:Daniel Waisberg
Language: eng
Format: mobi, epub
Published: 2015-04-25T03:56:54+00:00


Mobile Apps Integrations 79

Step 3: Add Campaign Parameters to Your Links to iTunes

This step is very similar to Google Play’s instructions for Android as described in Step 3 in the previous section. The only diff erence is that iOS links will require additional parameters: Google Analytics Property ID, Ad Network, and Redirect URL. You can fi nd the iOS Campaign Tracking URL Builder (see Figure 4-6) at http://goo.gl/Arg8tw.

Figure 4-6: iOS Campaign Tracking URL Builder

Step 4: Customize the iOS SDK to General Campaign Tracking

and Traffi c Source Attribution

Similarly to the process described for Google Play (Step 4 from the previous section), in order to capture traffi

c sources for users who land directly in your app (after installing it, in subsequent sessions), c04.indd 03/25/15 Page 79

80 Chapter 4 Mobile Apps Integrations

you will still need to tag your links as described in Step 3 so that Google Analytics understands where the user comes from. In addition to that, you also need to use [GAIDictionaryBuilder

setCampaignParametersFromUrl:urlString], where urlString is a string representing an URL that

may contain Google Analytics campaign parameters. Here is an example of how to do it (for the

source, go to http://goo.gl/KHVs17):

/*

* MyAppDelegate.m

*

* An example of how to implement campaign and referral attribution. If no

* Google Analytics campaign parameters are set in the referring URL, use the

* hostname as a referrer instead.

*/

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *) url {

NSString *urlString = [url absoluteString];

id<GAITracker> tracker = [[GAI sharedInstance]

trackerWithName:@"tracker" trackingId:@"UA-XXXX-Y"];

// setCampaignParametersFromUrl: parses Google Analytics campaign

// ("UTM")parameters from a string url into a Map that can be set on a Tracker.

GAIDictionaryBuilder *hitParams = [[GAIDictionaryBuilder alloc] init];

// Set campaign data on the map, not the tracker directly because it only needs

// to be sent once.

[[hitParams setCampaignParametersFromUrl:urlString] build];

// Campaign source is the only required campaign field. If previous call did

// not set a campaign source, use the hostname as a referrer instead.

if(![hitParams valueForKey:kGAICampaignSource] && [url host].length !=0) {

// Set campaign data on the map, not the tracker.

[hitParams set:kGAICampaignMedium value:@"referrer"];

[hitParams set:kGAICampaignSource value:[url host]];

}

[tracker send:[[[GAIDictionaryBuilder createAppView] setAll:hitParams] build]];

c04.indd 03/25/15 Page 80

Mobile Apps Integrations 81

APP TRAFFIC SOURCE ATTRIBUTION

When you fi nish the integration (either Android or iOS), you will be able to see the sources of your acquisition campaigns and subsequent app sessions. Awesome. However, there remains

one important question: how does Google Analytics attribute a source to a session? There are

four possible ways for a user to reach an app, but only two outcomes when it comes to the way

the source attribution behaves.

■ The user opens the app without clicking on an external link: the current session will be

attributed to the original source.

■ The user clicks on an external link that does not include the campaign parameters (explained in Step 3 in the previous section): the current session will be attributed to the original source.

■ The user clicks on an external link that includes the campaign parameters but the SDK was

not modifi ed to capture those links (as explained in Step 4 in the previous section): the

current session will be attributed to the original source.

■ The user clicks on an external link



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.