Search code examples
google-analyticsamp-html

Google Analytics on AMP does not send custom dimensions


This used to work before but now when I add the following code snippet, from the Google Analytics AMP integration page, it does not make a network collect call for Google analytics https://developers.google.com/analytics/devguides/collection/amp-analytics/#extending_googleanalytics

<amp-analytics type="googleanalytics" id="analytics1">
<script type="application/json">
{
  "requests": {
    "pageviewWithCd1Cd3": "${pageview}&cd1=${cd1}&cd3=${cd3}"
  },
  "vars": {
    "account": "UA-XXXXX-Y"
  },
  "triggers": {
    "trackPageviewWithCustom" : {
      "on": "visible",
      "request": "pageviewWithCd1Cd3",
      "vars": {
        "title": "Classic Cars",
        "cd1": "registeredUser",
        "cd3": "automotive"
      }
    }
  }
}
</script>
</amp-analytics>

I replaced the account with a real account starting with UA

I also have the analytics script tag included in the head tag:

<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>

The pageview does fire a request to collect but the cd1 and cd3 do not get included in the query params nor does the values of cd1 and cd3 get passed in the query params of the URL.

Have others noticed this same issue starting November 17th onwards?


Solution

  • You can follow the related github thread on the Chrome error here: https://github.com/ampproject/amphtml/issues/6740#issuecomment-268119523