General Attribution for Native Apps

Subscribe to our monthly newsletter to get the latest updates in your inbox

In the previous post we covered some best practices on how to load Google Tag Manager (GTM) for native apps. The default container needs to be updated or dataLayer pushes need to be batched in order to track hits that occur when the application launches. Obviously, this is important if we want to track how users are opening the app. This blog will describe the general strategy to track deep link and push notifications opens so conversions may be attributed back to these. The first thing that needs to be done is to determine how deep link and push notifications will be tagged. I recommend using UTM parameters (&utm_medium=<value>) for deep links and campaign related keys (medium : <value>) for push notifications. Any approach is fine as long as the information is tagged consistently. Now that we have consistent places to expect campaign information to enter the app, we need to send that information into GTM. The campaign information needs to be parsed out of the deep link URL when the app is launched or pulled out of the push notification payload. Next, this campaign information needs to be pushed into the dataLayer. Note, it is critical that this dataLayer push is the first push after the app launches. This will start a new session because we are setting campaign information. The session will break if we set the campaign information on a non-initial dataLayer push.   iOS Example:        [[TAGManager instance].dataLayer push:@{@"event":@"appInit",                                                @"campaignSource":@"<SOURCE>",                                                @"campaignMedium":@"<MEDIUM>",                                                @"campaignName":@"<CAMPAIGN>",                                                @"campaignTerm":@"<TERM>",                                                @"campaignContent":@"<CONTENT>"}];   Android Example:        dataLayer.pushEvent("appInit", DataLayer.mapOf(                                                "campaignSource", "<SOURCE>",                                                "campaignMedium", "<MEDIUM>",                                                "campaignName", "<CAMPAIGN>",                                                "campaignTerm", "<TERM>", "campaignContent", "<CONTENT>" ));   Next we'll need to configure GTM. We need to configure the tag to set campaign information. To do this we'll utilize the tag's Field to Set option. We can directly set the measurement protocol query parameter keys and values with this feature. See the screenshot below:   This tag should only fire first and once per app launch. Failure to meet this requirement may cause session breaking. There you have it! Once this container is published, default container updated, and code added to the app, campaign information should start populating the attribution reports in Google Analytics. Now we can start to understand how effective specific campaigns are towards ecommerce and/or goal conversions.