I am trying to assign content grouping variable to my Google Analytics code in my AMP markup.
My AMP analytics code:
<amp-analytics type="googleanalytics" id="analyticsgoogle1">
<script type="application/json">
{
"vars": {
"account": "UA-XXXXXXXX-X"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
}
}
}
</script>
</amp-analytics>
My regular Google analytics 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-XXXXXXXX-X', 'auto');
ga('set', 'contentGroup1', 'My Category');
ga('set', 'contentGroup2', 'My Author Type');
ga('set', 'contentGroup3', 'My Author Name');
ga('send', 'pageview');
</script>
I know it isn't listed in the documentation, but I am looking for something like this to possibly work so that my AMP pages can be tracked the same way as my regular pages.
Possible AMP Project Google Analytics Code with Content Grouping:
<amp-analytics type="googleanalytics" id="analyticsgoogle1">
<script type="application/json">
{
"vars": {
"account": "UA-XXXXXXXX-X"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
"vars": {
"contentGroup1": "My Category",
"contentGroup2": "My Author Type",
"contentGroup3": "My Author Name"
}
}
}
}
</script></amp-analytics>
I do not see the content grouping variables when to look at the documentation for Variables supported in amp-analytics: https://github.com/ampproject/amphtml/blob/master/extensions/amp-analytics/analytics-vars.md
Here is the documentation on amp-analytics code: https://developers.google.com/analytics/devguides/collection/amp-analytics/