Missing parameters from amp-analytics Google Analytics request on certain accounts
See original GitHub issueWhen a Google Analytics property is set up in a particular way, parameters such as “cd1” or “cg2” (custom dimensions or content groups) disappear from the “collect” call to Analytics and the information is not logged.
How do we reproduce the issue?
See the code in [http://output.jsbin.com/hamazex], which is essentially the simplest possible code for amp-analytics
, with the addition of a cd1 parameter.
Here is the relevant code:
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
...
<amp-analytics type='googleanalytics' id='myamppage'>
<script type='application/json'>{"requests":{"pageviewWithCds":"${pageview}&cd1=MyCustomValue"},"vars":{"account":"UA-2993209-3"},"triggers":{"trackPageview":{"on":"visible","request":"pageviewWithCds"}}}</script>
</amp-analytics>
Run it and observe the following call to Google Analytics:
https://stats.g.doubleclick.net/r/collect?v=1&aip=1&t=dc&_r=3&tid=UA-2993209-3&cid=amp-PKlrqV5acHC1a-VyvzS59ePh70Z16kVIBCLtI2Hwk68HenYqmMEJZcPYb_PNAZ9L&jid=0.49705940948446514&_v=a1&z=0.2638129200599211
Note the following:
- Because of the settings on the account, this has gone to doubleclick.net, not to google-analytics.com
- There is no cd1 parameter, in spite of this being specified in the markup.
If you use a GA account configured to go to google-analytics.com/collect, there is no problem: the parameters are included correctly.
Update: a newly created GA account, with no special features enabled, goes to google-analytics.com. It’s switched to doubleclick by one of the following settings in Google Analytics Admin: “Enable Demographics and Interest Reports”, “Remarketing” or “Advertising Reporting Features” - it’s hard to tell which, because the system takes several hours to respond.
What browsers are affected?
My test setup is Chrome / OS X. I very much doubt that it’s browser-related.
Which AMP version is affected?
Version 1481320064935
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (6 by maintainers)
The fix for the Chrome bug has been committed and was in the canary version 57.0.2979.0 as of 2017-01-12
Yes, this is a chrome bug. GA config does not directly send data to doubleclick. If you are seeing the request to doubleclick, that means GA got the data and requested a redirect. (also, to confirm things are working, try going to realtime reports and see if data shows up there.)