Jump to content

Do I need to change my Google Analytics code snippet from UA to GA4 ?


Go to solution Solved by Randy Calvert,

Recommended Posts

A year or two ago I've set up my GA4 property in Google Analytics and it did not require changing my code snippet, so my website is still using the old UA code snippet for the GA4 data flow (which works fine - I see in GA4 that my data collection is active). 

However I wonder if I should change the old snippet currently used on my site: 

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

And instead use the new one: 

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

Does that make a difference? 

Link to comment
Share on other sites

I'm still using the old one, it's working as expected (I suppose because inside Google Analytics I've linked it to my GA4 property) but I'm wondering if I need to change it or not, or if one presents advantages over the other. I suppose that just to be up to date I may change it to the new one, I'm just used to "if it ain't broken, don't fix it...".

Link to comment
Share on other sites

53 minutes ago, David N. said:

I'm still using the old one, it's working as expected (I suppose because inside Google Analytics I've linked it to my GA4 property) but I'm wondering if I need to change it or not, or if one presents advantages over the other. I suppose that just to be up to date I may change it to the new one, I'm just used to "if it ain't broken, don't fix it...".

Google Analytics Universal Analytics (UA) will soon be going away and you will need to convert to their GA4 scripts. Can read more from Google: https://support.google.com/analytics/answer/11583528?hl=en

Link to comment
Share on other sites

1 minute ago, Jim M said:

Google Analytics Universal Analytics (UA) will soon be going away and you will need to convert to their GA4 scripts. Can read more from Google: https://support.google.com/analytics/answer/11583528?hl=en

Oh yes I'm well aware, thanks. The UA property will stop processing data on July 1, 2023. However the UA script I'm using still works fine in creating a GA4 data stream, which is all the GA4 property requires to process data. 

Maybe I'm overthinking this and it doesn't matter in the end. 

Link to comment
Share on other sites

  • Solution
5 hours ago, David N. said:

Oh yes I'm well aware, thanks. The UA property will stop processing data on July 1, 2023. However the UA script I'm using still works fine in creating a GA4 data stream, which is all the GA4 property requires to process data. 

Maybe I'm overthinking this and it doesn't matter in the end. 

That's a question to pose to Google forums.  I personally switched to the recommended GA4 code to prevent potential dataloss.  It took all of a few minutes to update.  

Link to comment
Share on other sites

11 hours ago, Marc Stridgen said:

This is not to say they wont force onto the new one once they remove GA3 however. 

Yes indeed it looks like it would make sense. 

I've been wondering about the impact of Google Analytics on page speed lately. I know there are some alternatives to Google Analytics (such as abralytics) that improve page speed. However I can't use those as my ad manager requires Google Analytics. 

I'm still wondering if there's a difference between the UA and the GA4 scripts (I intend to test this soon and post my results here), and if data stream enhanced measurement settings (scrolls, outbound clicks, site search etc...) affect page speed (not sure how to test that). 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...