Wp-calypso: Google Analytics / Traffic: Update settings page to accept Google Analytics 4 properties

Created on 21 Oct 2020  ·  24Comments  ·  Source: Automattic/wp-calypso

Quoting @rantoncuadrado from internal post at p58i-9Dr-p2

As of October 14, 2020, a Google Analytics 4 property (formerly known as an “App + Web” property) is now the default when you create a new property. Universal Analytics refers to the previous generation of Analytics. This was the default property type for websites prior to October 14, 2020. Learn more.

GA4 properties have a different tracking ID format (they are not properly called tracking IDs but Measurement IDs). Measurement IDs are not accepted in My Site > Tools > Marketing > Traffic Google Analytics section in our dashboard.

This will also impact Jetpack connected self-hosted sites that attempt to use this feature.

Due to G4A property IDs being the new default, this will likely lead to an increase in support requests from users attempting to add an ID that doesn't work. Additionally, the workaround to get the universal ID is a bit tedious.

https://github.com/Automattic/wp-calypso/blob/master/client/my-sites/site-settings/form-analytics.jsx

Steps to reproduce

  1. Attempt to enter new GA4 property ID into My Site > Tools > Marketing > Traffic > Google Analytics Tracking ID

Context / Source

p58i-9Dr-p2

Analytics Involves Happiness Marketing [Pri] High

Most helpful comment

I am seeing quite a few instances of users not being able to add the code, and It looks like other HEs are seeing the same problem. I am going to reopen the issue, so we can review it. Thank you!

All 24 comments

This is big. Working on a quick fix.

I am seeing quite a few instances of users not being able to add the code, and It looks like other HEs are seeing the same problem. I am going to reopen the issue, so we can review it. Thank you!

@mrfoxtalbot Ouch. Can you point me to one or two? I'm happy to jump into following up and fixing it.

Absolutely! Let me grab a few examples and I will get back to you.

In the meantime, I have an idea what might be going on.

The new GA4 format is as follows: G-XXX123YYYY, where the X, Y are any capital letters, and numbers can be any numbers.

Is it possible that the users are trying only with the XXX123YYYY part? If that's the case, can we try directing them to add the entire code, with the G- in the beginning?

cc @retrofox @allilevine @creativecoder who're fixing this on the API side on both WP.com and Jetpack.

Let us close it and feel free to open it again if detect the issue persist

This seems to be still ongoing, we've logged a few new cases at https://github.com/Automattic/wp-calypso/issues/47031 but I'm re-opening this one for visibility.

Another where the G- format didn't work 25380805-hc

Also ran into this today in 23167378-hc

And another one 25347301-hc

I'd like to note that this issue is expected to still occur for Jetpack and Atomic sites, as it has been fixed, but slated for release with Jetpack 9.1 on 2020-11-10. We expect that with Jetpack 9.1, the issue will disappear.

Reported here: #20737816-hc

Another user reported here: 17750229-hc
Follow-up ticket: 3470056-zd-woothemes

They say that stats aren't being tracked after switching to the new GA4 Measurement ID on both of their sites.

Reported on #2697478-hc

I've shared plugins as an alternative for now.

Hi all, I ran into this issue here: #3466089-zd and it seems the new tracking code was accepted but there's a couple messages in their GA account:

_Invalid or Missing Web Proper ID_ and
_Code found outside of tag_ (verified this through browser inspector)

I'm not clear whether they are getting any stats or not so I just asked in the ticket. I didn't get an error message when I put in their new tag - it said the new configuration was saved successfully with the green checkmark so it _looks_ to be connected but they are getting those messages above.

Another report here: 3483879-zd-woothemes

I suggested they use the UA code for now.

Another report in 3488344-zd that measurement ID is not working.

user in 3488344-zd mentioned that the code they need as per Google is

the one I see on page source is

Another report here #23753857-hc

Reported in #25733887-hc

As a workaround, they I asked them to add the script directly from Google into their header. Jetpack's code didn't match the code from Google. Within a minute or two, they said they were receiving data in their Google Analytics account.

Jetpack's code:

<!-- Jetpack Google Analytics -->
<script type="text/javascript">
                var _gaq = _gaq || [];
                _gaq.push(['_setAccount', 'G-TRACKING-ID-HERE']);
_gaq.push(['_trackPageview']);
_gaq.push(['_gat._anonymizeIp']);
                (function() {
                    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                    ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
                })();
            </script>

Google's code:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-TRACKING-ID-HERE"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-TRACKING-ID-HERE');
</script>

Just adding an update here that I will also crosspost elsewhere it might be useful for others. As of now Calypso will accept the new Measurement ID that required the newer GA4 script on the site. The issue is that we don't yet insert the GA4 compatible script - only the older ga.js version from the older Universal Analytics ID.

This is being worked on in a couple of places. To note it is here for Jetpack sites - https://github.com/Automattic/jetpack/pull/17795

For internal post update see p58i-9Dr-p2#comment-48258

GA4 property IDs should now be tracking properly in the Google Analytics dashboard for Simple sites. Jetpack fix is still in progress, and planned for the next scheduled release on December 1st.

Was this page helpful?
0 / 5 - 0 ratings