I want to enable demographics and interests reports with the Universal Analytics tracking code.
The generated tracking code for my site looks like this:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-999999999-9', 'whatever.com');
ga('send', 'pageview');
</script>
Under Display Advertiser Features there is a option saying:
Demographics and Interest Reports make Age, Gender, and Interest data available so you can better understand who your visitors are. To see this data, you need to make a small change to your tracking code. Learn more about how to make these tracking code changes.
It links to: https://support.google.com/analytics/answer/2444872?hl=en&utm_id=ad
Which basically tells me to replace:
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www')
+ '.google-analytics.com/ga.js';
With:
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://')
+ 'stats.g.doubleclick.net/dc.js';
But this seems to target a different version of Analytics (Classic Analytics tracking code, and I am using the new Universal Analytics)...
Should I just replace:
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
With something? (E.g.)
})(window,document,'script','//stats.g.doubleclick.net/analytics.js','dc');
Also, do I really need to enable Advertiser Features in order to track visitors age and gender? I have currently no intention in using AdSense.
As I know , the feature is not available for Universal Analytics until phase 3.
This link has more information about Universal Mode: https://developers.google.com/analytics/devguides/collection/upgrade/
Refer the article below for more info about do it in Classic Mode. http://online-behavior.com/analytics/demographics
The upgrade page has the following content under the section "Important Considerations" (emphasis hjpotter92):
Data integrations related to the dc.js JavaScript library aren’t supported, but are coming soon.
The
dc.js
JavaScript library isn't supported in Universal Analytics, but will be in the coming year. If you rely ondc.js
related features, such as Remarketing, Google Display Network Impression Reporting, DoubleClick Campaign Manager Integration, or Google Analytics Demographics and Interests Reports, do not upgrade to Universal Analytics yet. Wait until you see an announcement aboutdc.js
in Universal Analytics, and upgrade then.