Learn business growth with Google Analytics 4 Forums Google Analytics 4 Making the Switch to GA4: Handling Legacy Code

  • Making the Switch to GA4: Handling Legacy Code

    Posted by Raj on 15 November 2022 at 11:33 pm

    “Hiya folks, newbie here. I’ve been roped into moving my company’s analytics over to GA4, but the thing is, I’ve never messed around with this stuff before. I’ve set up a new property on the google analytics page and popped this code just under the head on the website.


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

    gtag('config', 'G-XXXXXXXXX');
    </script>

    Now I’m kinda stuck.

    1. Should I get rid of the old UA tracking code on the website? Will the sky fall if I leave it with the GA4 code?
    2. Do I need to do anything specific with the old events, or will GA4 use some magic to move them over on its own? You know, the ga('send', {xxxx}) ones?

    Any help you can give me would be absolutely brilliant. Cheers!

    P.S. I’ve connected the original UA to GA4, and both bits of analytics code are hanging out on the website. I can see it tracking data as users click around. I’m just worried it might kick the bucket come July 1st when UA wraps up.”

    Benjamin replied 1 year ago 3 Members · 2 Replies
  • 2 Replies
  • Amit

    Member
    7 February 2023 at 9:54 pm

    Hey there! Great job on setting up GA4 and connecting it with your original UA. Now, you don’t have to worry about the UA discontinuation, GA4 got you covered.

    If you feel the need, you can start shifting to GA4 more seriously by tracking onto a different property, while slowly getting your data folks familiar with GA4, including understanding the different metrics and dimensions.

    You may wonder about why we’re messing around with gtag if analytics.js serves the same purpose. Well, in theory, yes. But Google only permits analytics.js tracking format to transform it into GA4 data format and unfortunately, updates or maintenance for analytics.js are not expected after the discontinuation. It’ll keep working but limitations may arise over time.

    Your next move could be to eliminate your direct inline analytics function calls and transfer this logic to Google Tag Manager, its rightful place. So basically, you’re on the right track, now it’s just about progressing step-by-step. Keep it up!

  • Benjamin

    Member
    24 March 2023 at 2:53 pm

    You can certainly keep your old Universal Analytics property while starting to use your new Google Analytics 4 (GA4) property, to ensure that all tracking is ongoing while you adjust to the new system. It won’t affect your GA4 data. Whether to keep the old UA tracking code or not, it completely depends on your requirements. Regarding the old events, GA4 will not automatically transfer them. GA4 works with a different event model than UA, and you’ll need to set them up manually in GA4 once again. Old ‘ga(‘send’) events can’t be directly transferred. The GA4 event model is more flexible and allows for more customization so you might consider mapping out how you want to track events in GA4, and implement those changes gradually. Also, though your existing UA property won’t stop working after July 1st, Google will stop creating new properties in UA, hence building comfort with GA4 will be useful for future analysis.

Log in to reply.