Setting up "Advertising Features" in Google Analytics for iOS and Android
This article explains how to set up advertising features for Google Analytics in iOS and Android.
Background
The native Google Analytics SDK for Android and iOS provides a method to enable advertising features, such as demographics and interest reporting. If you implement GA via Tealium’s SDK, however, you do not get these features by default. The main reason for this is that not all Tealium users require advertising data, and if it was included by default, additional permissions would be required at install time.
Prerequisites
- In order to use this feature, you will need to ensure that the following data is exposed in the data layer in your app, via the Tealium tracking API:
- Android advertising ID (aka “ADID”) - see Appendix A below for details on setting this up
- iOS ID for advertisers (aka “IDFA”) - see Appendix B below for details on setting this up
- Additionally, you must ensure that your Google Universal Analytics tag template is on a version later than 20151026 (26 October 2015). If you are unsure, please use the Tag Status Checker tool to verify the template version in your profile. Please ensure that your current tag template is not customized before you upgrade, or you risk losing existing functionality. If unsure, please speak to your account manager.
- Ensure you have enabled demographics and interest reports in your Google Analytics property. This task must be completed by a GA admin from within your GA account settings.
Configuring the GA tag
-
Add new data sources in Tealium IQ to represent the ADID and IDFA parameters that will be passed in to the Tealium API by your mobile app developers. Data source names
idfa
andadid
will suffice, but ensure that the app developers are using the same names as those you have specified in the UI, or this will not work. -
One additional parameter is required, to signal to GA that the ad tracking feature is enabled. To set this up, we need one extra data source, which will eventually be mapped to the
ate
parameter in GA:
-
Add a new Set Data Values extension, and set your new ad tracking data source to string value
1
: -
Configure your mappings as follows. Please note that the
&
(ampersand) symbol is deliberate, and forms part of the mapping name. These mappings will need to be entered manually as custom mappings, as they are not currently in the mapping toolbox: For simplicity of copying & pasting the mapping names, here they are in text form:
set.&idfa
set.&adid
set.&ate
- Once all the above items are configured, save and publish your profile. Even if you do not currently have ADID and IDFA in your data layer, you can still add these mappings in advance, and they will only become active once your developers have added these to your apps.
Important Notes
Please note that once this feature is enabled, it may take up to 24 hours for data to appear in GA. If you have too few hits, GA will not show any data, as this could inadvertently identify individual users. Certain thresholds of traffic must be reached before GA will allow you to see the data for privacy reasons.
Appendix A - Adding ADID to the data layer on Android
This guide explains how to retrieve the ADID on Android. Please note this is an external link, and Tealium has no control over its contents:
https://www.safaribooksonline.com/blog/2014/01/16/advertising-id-android-kitkat/
Once you have retrieved the ADID, you can use the following API calls to add the data via the Tealium Android SDK. This will make the data available on each subsequent hit within the app, and the value will persist between app launches:
Tealium SDK v4.x
Tealium.getGlobalCustomData().edit().putLong("adid", "<your advertising id here>").apply();
Tealium SDK v5.x:
Tealium.getInstance("instancename").getDataSources().getPersistentDataSources().edit().putString("adid", "<your advertising id here>").apply();
NB: Substitute instancename
for the actual instance name you are using in the app, and be sure to replace the placeholder text with your actual ADID.
Appendix B - Adding IDFA to the data layer on iOS
This guide explains how to retrieve the IDFA on iOS. Please note this is an external link, and Tealium has no control over its contents:
http://www.brianjcoleman.com/how-to-use-apples-identifier-for-advertisers-idfa/
Once you have retrieved the IDFA, you can use the following API calls to add the data via the Tealium iOS SDK. This will make the data available on each subsequent hit within the app, and the value will persist between app launches:
Tealium SDK v4.x
[Tealium addGlobalCustomData:@{@"idfa" : @"<your idfa here>" }];
Tealium SDK v5.x
[[Tealium instanceForKey:@"instancename"] addPersistentDataSources: @{@"idfa":@"<your idfa here>"}];
NB: Substitute instancename for the actual instance name you are using in the app, and be sure to replace the placeholder text with your actual IDFA.
This page was last updated: November 11, 2016