Mobile app version of vmapp.org
Login or Join
Miguel251

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

@Miguel251

Posted in: #Amp #GoogleAnalytics

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 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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Miguel251

1 Comments

Sorted by latest first Latest Oldest Best

 

@Barnes591

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme