NEU-Libraries / scholar-onesearch

Scholar OneSearch - Northeastern University Libraries' Primo implementation CSS/JS and HTML code snippets.
scholaronesearch.northeastern.edu
10 stars 4 forks source link

Migrate to using Google Analytics V4 (target Jul 1, 2023) #437

Open nestochan opened 1 year ago

nestochan commented 1 year ago

the custom.js file has the coding used to use Google Universal Analytics which is being replaced by G4

following code will likely need to be placed into our custom.js either in addition to or replacing current UA code block with the new G4 block below.

**

<!-- Google tag (gtag.js) -->

<script async src="https://www.googletagmanager.com/gtag/js?id=G-QYFS4PG2RV"></script>

<script>

  window.dataLayer = window.dataLayer || [];

  function gtag(){dataLayer.push(arguments);}

  gtag('js', new Date());

  gtag('config', 'G-QYFS4PG2RV');

</script>

**

gam5 commented 1 year ago

New GAv4 code added to all production views custom.js files. Old version still in place for now.

* / START - Google Analytics v4 */ var googleAnalyticsUrl = document.createElement('script'); googleAnalyticsUrl.src = "https://www.googletagmanager.com/gtag/js?id=G-QYFS4PG2RV"; googleAnalyticsUrl.type = 'text/javascript'; googleAnalyticsUrl.async = true; document.head.appendChild(googleAnalyticsUrl);

var googleAnalyticsCode = document.createElement('script'); googleAnalyticsCode.innerHTML = window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-QYFS4PG2RV');; document.head.appendChild(googleAnalyticsCode); / END - Google Analytics v4 /

**

gam5 commented 1 year ago

Will close once tested.