question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing parameters from amp-analytics Google Analytics request on certain accounts

See original GitHub issue

When 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:

  1. Because of the settings on the account, this has gone to doubleclick.net, not to google-analytics.com
  2. 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:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jpettittcommented, Jan 19, 2017

The fix for the Chrome bug has been committed and was in the canary version 57.0.2979.0 as of 2017-01-12

0reactions
avimehtacommented, Dec 29, 2016

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.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

AMP Reporting guide - Analytics Help - Google Support
To open your new report from anywhere in Google Analytics, click Customization > Custom Reports > AMP vs Non-AMP performance. Click +Add Segment....
Read more >
Documentation: <amp-analytics> - amp.dev
Captures analytics data from an AMP document. ... This parameter is used by Google to trigger experiments for the Google AMP Cache.
Read more >
AMP-Analytics: Errors with Google Tag-Manager · Issue #13005
The work-around I can see for this is to manually append the __amp_source_origin parameter to the end of the amp-analytics config URL. However ......
Read more >
How to track AMP Pages with Google Analytics 4 - David Vallejo
User Properties; Event Parameters. One of the most notorious misses on Google Analytics 4. Is the lack of AMP (Accelerated Mobile Pages) ...
Read more >
Error Bad Request: Missing parameter: 'code' - WordPress.org
I have tried the Health Check & Troubleshooting, and I've tried using a default theme and the error persists.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found