April 15, 2021

Google Analytics 4 for Blogger keeping Universal Analytics

I have tried to update my Blogger blog to the new Google Analytics tracking (GA4). But I have noticed that my old tracking with Universal Analytics was discontinued (data won't be fed).
Here is the solution I have come to fix it and keeping using UA and GA4 tracking in parallel.

Tried configuration

UA connected to new GA4
In blogger edit HTML theme and add the tracking code snippet:

<!-- Global site tag (gtag.js) - Google Analytics --> <script async='async' src='https://www.googletagmanager.com/gtag/js?id=UA-84853115-1'/> <script>   window.dataLayer = window.dataLayer || [];   function gtag(){dataLayer.push(arguments);}   gtag(&#39;js&#39;;, new Date());   gtag(&#39;config&#39;, &#39;UA-84853115-1&#39;);   gtag(&#39;config&#39;, &#39;G-FJS6JR3WS0&#39;); </script>
Unfortunately with this approach, the data for the UA tag stopped to be fed. (but the GA4 data is properly fed.)

Fix using Google Tag Manager

I have replaced the normal tracking by the usage of the Google Tag Manager (GTM)


Adding the UA tag was a bit tricky: you need to add the UA Tracking ID as variable.

GTM in Blogger Theme

You need to add the GTM Tracking code snippet in the theme HTML under the <head>

Note that you need to replace the red & by &amp; as explained here.



Test/ Connect

Troubles I got:
To test debug preview I had to do this in incognito mode (It seems some extensions were blocking the test.) Else I got a could not connect to a tag / time-out error.

Now after the test I see again a view in my GA Report for the UA tracking :-)


Strangely for my GitHub.io Homepage the connection/ upgrade from UA to GA4 was seamless and both data are tracked/ fed.
When updating my blogger GA I could not check this checkbox: Enable data collection using existing tags. etc

No comments:

Post a Comment