Can i turn demographics off in Google analytics in the embed code?

Hi,
we want to be able to only record demographics in google analytics if the user says it is ok to do so, as it is technically personally identifiable data. If the user says no i want to be able to still run the analytics but without the demographics bit.

On this page https://www.stefanmaescher.com/google-analytics-display-features/ it shows the embed code

<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-XXXXXX-XX', 'example.com');
ga(‘require’, ‘displayfeatures’);
ga('send', 'pageview');
</script>

and says the line ga(‘require’, 'displayfeatures’); is the bit that enables the demographics. Does this mean that i can remove this as necessary to turn on or off the demographics but still track other metrics? (i know demographics needs to be turned on in the GA admin).

Obviously i can then use a cookie etc to control the users response and add or remove the line.

Would this work?

Thanks

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.