David N. Posted June 28, 2023 Posted June 28, 2023 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?
Marc Posted June 28, 2023 Posted June 28, 2023 If you are using the new one, you have the correct one. David N. 1
David N. Posted June 28, 2023 Author Posted June 28, 2023 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...".
Jim M Posted June 28, 2023 Posted June 28, 2023 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
David N. Posted June 28, 2023 Author Posted June 28, 2023 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.
Solution Randy Calvert Posted June 29, 2023 Solution Posted June 29, 2023 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. David N. 1
David N. Posted June 29, 2023 Author Posted June 29, 2023 Ok thank you @Randy Calvert, I will ask there.
David N. Posted June 29, 2023 Author Posted June 29, 2023 According to my Ad Manager, I should keep the UA code and I'm all set. I may still run some performance tests to see if one code is faster than the other. If I find out anything I'll post it here.
Marc Posted June 30, 2023 Posted June 30, 2023 I believe it will actually work with either at present. This is not to say they wont force onto the new one once they remove GA3 however. David N. 1
David N. Posted June 30, 2023 Author Posted June 30, 2023 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).
Recommended Posts