I have a website that is running the Universal Analytics (UA) version of Google Analytics. I would like to add support for Google Analytics 4.

The documentation for adding Google Analytics 4 support asks me to add a gtag.js script to my web pages. If I want to continue using UA, do I need to use both analytics.js and gtag.js, or can I just replace the analytics.js tag with gtag.js because it will be enough to supply data to both UA and GA4?

1 Answer 1


In this Google documentation page about adding the gtag.js tag, under the "if the setup wizard did not use your existing tagging" section, under the "add your tag directly to your web pages" accordion, Google says:

Don't remove the old analytics.js tag; it will continue to collect data for your Universal Analytics property. The gtag.js tag that you're adding will collect data for your new Google Analytics 4 property.

So the answer is that both tags are needed.

  • While drafting this question, I came across the answer buried in the documentation. I decided to post this Q&A anyways so that other people might have an easier time of finding the answer than I did. Sep 26, 2021 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.