0

This used to work before but now when I add the following code snippet, from the Google Analytics AMP integration page, it does not post custom dimensions on the network collect call it makes 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?

1 Answer 1

1

You can send custom dimensions as extraUrlParams like seen below

<amp-analytics type="googleanalytics" id="analytics-magazin">
    <script type="application/json">
    {
       "vars": {
             "account": "UA-72961156-8"
       },
       "extraUrlParams": {
             "cd11": 3,
             "cd15": "xxx",
             "cd16": "yyy",
             "cd25": [
                    "aaa","bbb"
                    ],
             "cd18": "1"
       }
    }
   </script>
</amp-analytics>

Don't forget to add triggers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.