NIH | National Cancer Institute | NCI Wiki  

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Many older applications were coded using analytics.js.  GA4, and newer implementations of UA, use gtag.js.  Pages will need to be updated to gtag to enable migration, if they don't use it already.  Once gtag is present, Google should be able to receive data to both UA and GA4, up until UA cutoff date in July. This will allow users to configure GA4 data and reports to match what was received in UA. 

The old analytics.js scripting will look like this and should be removed:be replaced by gtag.js text. The proper gtag text can be generated in Google Analytics.

Code Block
titleapplication.js
<head>
…other stuff…

<script>(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,"script","//www.google-analytics.com/analytics.js","ga");ga("create", "UA-150112876-1#########", {"cookieDomain":"auto"});ga("send", "pageview");</script>

…other stuff…
</head>

...

On Google Analytics go to Admin and click the GA4 property for the application that you want to configure. Then click “Data Streams”.  Click the ">" to open the next page.

On the next page, at the top, click “View tag instructions”. 

...

On the “Installation Instructions” page click “Install Manually”.  The page should then display the text that you need to add to each HTML page in your application. The correct tag ID will already be in the text. You can copy this text and paste it into the web page at the appropriate location, replacing the analytics.js text.



 Once the gtag.js tagged page is deployed to production, data should be visible in GA4 and UA in around 30 minutes.  The UA data will cease collection on July 1, 2023.