Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Analytics 4 and AMP - "unknown ID" // documentation issue? #30903

Closed
jamescridland opened this issue Oct 29, 2020 · 24 comments
Closed

Google Analytics 4 and AMP - "unknown ID" // documentation issue? #30903

jamescridland opened this issue Oct 29, 2020 · 24 comments

Comments

@jamescridland
Copy link

jamescridland commented Oct 29, 2020

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.

@micajuine-ho
Copy link
Contributor

Hi @jamescridland, thetype="gtag" causes amp-analytics to use the gtag.json vendor config. This config uses the config-rewriter module, to fetch a custom config from the gtag server, and merge it with the inline config.
I believe what is happening is that your two gtag_ids reference different accounts or they're set up different and thus are getting different configs back (one with pageView triggers, the other without).

To test, you can check the network tab and see what is returned from the gtag config rewriter endpoint (https://www.googletagmanager.com/gtag/amp) when you use those different ids.

@jamescridland
Copy link
Author

Thanks for trying to help.

the type="gtag" causes amp-analytics to use the gtag.json vendor config

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.

your two gtag_ids reference different accounts

The G-BR6HXXXXX tag is the new Google Analytics 4 property. Absolutely, it's a different account than the UA-1002XXXXX-1 one. But the G-BR6HXXXXX tag is sourced from this screen in Google Analytics 4.

To test, you can check the network tab and see what is returned from the gtag config rewriter endpoint (https://www.googletagmanager.com/gtag/amp) when you use those different ids.

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:

{"vars":{"gtag_id":"G-BR6HXXXXX","config":{"G-BR6HXXXXX":{"groups":"default","site_speed_sample_rate":100}}},"configRewriter":{"vars":{"gclsrc":"","hasGcl":"0","hasDcl":"0","hasExtRef":"0","hasDocRef":"1"}}}

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

{"vars":{"gtag_id":"UA-1002XXXXX-1","config":{"UA-1002XXXXX-1":{"groups":"default","site_speed_sample_rate":100}}},"configRewriter":{"vars":{"gclsrc":"","hasGcl":"0","hasDcl":"0","hasExtRef":"0","hasDocRef":"1"}}}

The response, in full, is:

{"cookies":{"_ga":{"value":"$IF(LINKER_PARAM(_gl, _ga),GA1.0.LINKER_PARAM(_gl, _ga),)"},"_gac_UA-1002XXXXX-1":{"value":"$IF(LINKER_PARAM(_gl, _gac),1.LINKER_PARAM(_gl, _gac),)"}},"linkers":{"_gl":{"enabled":true,"ids":{"_ga":"${clientId}"},"proxyOnly":false}},"triggers":{"gtag_0":{"extraUrlParams":{"gtm":"2pu000"},"on":"visible","request":"uaPageview","vars":{"trackingId":"UA-1002XXXXX-1"}},"gtag_1":{"extraUrlParams":{"gtm":"2pu000","t":"timing"},"on":"visible","request":"uaTiming","sampleSpec":{"sampleOn":"${clientId}","threshold":100},"vars":{"trackingId":"UA-1002XXXXX-1"}},"gtag_2":{"enabled":"${queryParam(gclid)}","extraUrlParams":{"gtm":"2pu000","t":"adTiming"},"on":"visible","request":"uaTiming","vars":{"trackingId":"UA-1002XXXXX-1"}}},"vars":{"gtag_id":"UA-100XXXXX-1"}}

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

@micajuine-ho
Copy link
Contributor

Thanks for your response. I guess the answer to your original question is that it's a documentation issue. We should document that sometimes using type='gtag' might not work out of the box.

Using the gtag config with your original UA-1002XXXXX-1 gtag_id results in the gtag server returning a config with triggers. With your new gtag_id G-BR6HXXXXX a config is not being returned from their servers, resulting in no triggers being added.

The solution here would be to either inline your own triggers/requests within the amp-analytics tag (which will send data to your gtag account), or figure out why the gtag server is not returning a config with your new gtag_id.

I'm not a google analytics or gtag expert, but please let me know if you need me to clarify anything above.

@jamescridland
Copy link
Author

Thanks.

So, when this page says: "When amp-analytics is configured with a Google Analytics property ID, page_view events are automatically logged by default" then this is entirely incorrect?

This screenshot...
Screen Shot 2020-11-04 at 12 08 49 pm

... it says it's a basic setup to measure pageviews, but it doesn't measure pageviews.

How can get get this in front of Google Analytics or GTag experts? This documentation is plain incorrect.

@jamescridland
Copy link
Author

@micajuine-ho
Copy link
Contributor

I have reported this in the Google Analytics forum.

Awesome, thank you for reporting it to the GA team. I will close this issue for now, but if you need help setting up your analytics config, please feel free to reopen.

@jamescridland
Copy link
Author

This shouldn't be closed. Putting a link in a community forum isn't closing this issue.

@jamescridland
Copy link
Author

AMP-HTML's own documentation is incorrect. Please reopen this issue.

@micajuine-ho
Copy link
Contributor

I see your point. I can put a PR out to fix our docs :)

@micajuine-ho
Copy link
Contributor

AMP-HTML's own documentation is incorrect. Please reopen this issue.

Reading through the issue again, it seems like the problem problem with the documentation is this:

gtag is not listed as a valid vendor type yet is being suggested here.

Using the type attribute allows amp-analytics to pull in a stored config; this config doesn't have to be from a vendor. I believe in this case, using the Google Tag Manager config should help format your tracking requests (sent to your analytics vendor) in a specific way that GTM can do stuff with.

/cc @CrystalOnScript Do you know who we can contact to try to get the documentation (#30903 (comment)), fixed/easier to understand?

@micajuine-ho
Copy link
Contributor

micajuine-ho commented Nov 10, 2020

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?

@jamescridland
Copy link
Author

I've found out that as of now, Google Analytics 4 does not support AMP

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?

@summercms
Copy link

summercms commented Nov 15, 2020

How to let Google know their information page at: https://developers.google.com/analytics/devguides/collection/amp-analytics

Is not compatible with Google Analytics 4?

The page has a Rate and Review button, which let's you click on options, that is totally pointless and stupid! Because you can't actually tell Google what the real problem is.

ezgif-5-95148b443edf

Clicking the option Other and it sends the details without you being able to tell Google what the exact problem is - is complete madness!

I know there are some Googler's working in this repo! Please read my comment and pass it onto the team that deals with the information pages in Google Developers Analytics section. It just needs a blockquote at the top saying not compatible with Google Analytics 4.

@Beethoven
Copy link

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

@jamescridland
Copy link
Author

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?

@stephengardner
Copy link

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

@micajuine-ho
Copy link
Contributor

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.

@tripledm
Copy link

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.

Thank you!

@micajuine-ho
Copy link
Contributor

Closing this issue in favor of an existing duplicate issue #24621.

@tranduchieu
Copy link

Waiting

@tripledm
Copy link

Waiting

@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.

@erdalonline
Copy link

It's been the same conversation for about 2 years. Take care of this, please.

@yeshwantthota
Copy link

Is this issue still not resolved because i am getting the same problem.

@chriskyfung
Copy link

Hi @yeshwantthota.

GA4 is now supported by the official amp-analytics component. See: https://amp.dev/documentation/components/websites/amp-analytics#google-analytics-4-and-amp

Although it seems work, I agree it still stuck. I have no idea when it will support Google Consent Mode V2 (#39867)

Is this issue still not resolved because i am getting the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

11 participants