How to migrate from ga.js to gtag.js?

Member

by gilbert , in category: Third Party Scripts , 14 days ago

How to migrate from ga.js to gtag.js?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by dalton_moen , 12 days ago

@gilbert 

Migrating from ga.js to gtag.js can be done by following these steps:

  1. Update the Google Analytics tracking code on your website: Replace the ga.js tracking code with the gtag.js tracking code in the section of your website.
  2. Update the tracking code for events: If you have any custom event tracking implemented using ga.js, you will need to update the code to use the gtag.js syntax for event tracking.
  3. Update custom dimensions and metrics: If you are using custom dimensions and metrics in your Google Analytics setup, you will need to update the code to use the new syntax for custom dimensions and metrics in gtag.js.
  4. Test the tracking code: Once you have made the necessary updates to your tracking code, be sure to test that everything is working correctly by visiting your website and checking the Google Analytics reporting.
  5. Consider updating other Google services: If you are using other Google services that rely on the ga.js tracking code, such as Google Tag Manager, you may also need to update those services to use the new gtag.js tracking code.


By following these steps, you can successfully migrate from ga.js to gtag.js and continue tracking your website traffic and conversions with Google Analytics.