I have been trying to start tracking AMP pages in GA4 but getting amp validation error by adding below script in Body or head tag of the amp website.
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
<amp-analytics type="gtag" data-credentials="include">
<script type="application/json">
{"vars" : {
"gtag_id": "G-373W5TRB8C",
"config" : {
"G-373W5TRB8C": { "groups": "default" }
}
}
}
</script>
</amp-analytics>
https://support.google.com/analytics/answer/13707678
Add the following config to the Analytics tag on your AMP pages:
vars: { 'ampHost': '${ampdocHost}' }
Can anyone please help me about where to add above scripts on AMP pages? and if I need to make any changes in script.AMP Validation Error
I have added that script as per the steps shared by google but it is not working and receiving validation error.
https://www.searchenginejournal.com/google-analytics-4-now-supports-accelerated-mobile-pages-amp/490273/ https://searchengineland.com/amp-support-ga4-428705 https://support.google.com/analytics/answer/13707678