amphtml: Google Analytics 4 and AMP - "unknown ID" // documentation issue?
What’s the issue?
amp-analytics returns [AmpAnalytics <unknown id>]
error, and does not send information back to Google Analytics 4.
How do we reproduce the issue?
I’ve successfully set up a new Google Analytics 4 property. Under “Web Stream details”, it gives me a measurement ID of G-BR6HXXXXXX
(here’s an image of that).
It’s quite hard to find the Google Analytics 4 AMP setup code, which is not linked from the Google Analytics 4 documentation. I think this is the correct page which 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" }
}
}
}
</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. I don’t know if this is a bug, or just poor documentation.
- Have I found the “wrong” GA AMP-HTML setup page? What should this look like?
- Why aren’t AMP tagging instructions being linked-to from the “web stream” setup for Google Analytics 4? Please could it be?
- gtag is not listed as a valid vendor type yet is being suggested here.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 9
- Comments: 24 (8 by maintainers)
OK, well, that’s a shame. And somehow this needs to be clear in the documentation so that other developers don’t waste their time as I’ve done. Can that be made clear?
Hi all, thank you for your comments.
We are in the process of syncing with the GA4 team to get an estimate for the work need for GA4 to be supported in AMP. I will update here with more information once we get it.
@tranduchieu there is an open issue #24621 and we are all waiting but it won’t help to poke at the developers as they are working on a solution. This is a GA4 issue so it won’t be an easy or quick fix either.
Hi @jamescridland, I’ve found out that as of now, Google Analytics 4 does not support AMP and I am not sure if they are planning to support AMP in the near future. This is why there is no explicit documentation for GA4 integrations with AMP.
The documentation that you linked above applies to (and is still valid for) the previous version of Google Analytics and should continue to work with AMP.
Does this answer your questions?
It’s been the same conversation for about 2 years. Take care of this, please.
Our users using AMP for Shopify want to know how to add GA4 to AMP pages. Please provide some information or an expected ETA on compatibility
I am quite concerned that this is essentially communicating that Google has lost interest in AMP. Probably another Google Reader experience before too long. This is a real concern - how do we get some form of direction from the AMP team?
“The new Google Analytics is now the default experience for new properties and is where we’re investing in future improvements.” Vidhya Srinivasan Vice President, Measurement, Analytics, and Buying Platforms, Google
Where’s the AMP implementation? The docs?
Thanks for trying to help.
gtag
is not listed as a valid vendor type in the<amp-analytics>
documentation. I find this confusing.Nevertheless, it successfully calls this file in the network tab.
The
G-BR6HXXXXX
tag is the new Google Analytics 4 property. Absolutely, it’s a different account than theUA-1002XXXXX-1
one. But theG-BR6HXXXXX
tag is sourced from this screen in Google Analytics 4.For the Google Analytics 4 ID… in the network tab,
https://www.googletagmanager.com/gtag/amp?__amp_source_origin=https%3A%2F%2Fpodnews.net
is only called once. Its payload is:(I’m requesting 100% for site speed samples, by the way). The response, in full, is:
{}
The error in the console reads…
log.js:258 [AmpAnalytics <unknown id>] No triggers were found in the config. No analytics data will be sent.
For the old Google Analytics ID… in the network tab,
https://www.googletagmanager.com/gtag/amp?__amp_source_origin=https%3A%2F%2Fpodnews.net
is only called once. Its payload is:The response, in full, is:
…it then makes two
collect
calls; but this data is being loaded into the old Google Analytics, and not Google Analytics 4. This isn’t what I want.I’m confused that this page detailing AMP and Google Tag Manager looks so different from this page apparently detailing AMP and Google Analytics.