I've successfully set up a new Google Analytics 4 property. Under "Web Stream details", it clearly gives me a measurement ID of G-BR6HXXXXXX
.
The Google Analytics AMP setup code looks as though it should look like this:
<amp-analytics type="gtag" data-credentials="include">
<script type="application/json">
{
"vars": {
"gtag_id": "G-BR6HXXXXXX",
"config": {
"G-BR6HXXXXXX": { "groups": "default", "site_speed_sample_rate": 100 }
}
}
}
</script>
</amp-analytics>
However, this doesn't appear to collect any data, complaining, with an error message in the console:
log.js:258 [AmpAnalytics <unknown id>] No triggers were found in the config. No analytics data will be sent.
(Triggers aren't required here; this code should automatically measure page views; and adding triggers doesn't appear to fix this issue.)
I can switch the measurement ID to my old GA one - UA-1002XXXXX-1
- and it works fine.
I'm now confused as to what's up. Have I found the "wrong" GA AMP-HTML setup page? What should this look like? Why isn't AMP being linked-to from the "web stream" setup for Google Analytics 4?
You have to use Universal Analytics. GA4 is not yet supported in AMP
You can follow the issue: https://github.com/ampproject/amphtml/issues/24621
Read comment: https://github.com/ampproject/amphtml/issues/24621#issuecomment-824336265
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.