ukwa / ukwa-ui

A new user interface for the UK Web Archive
BSD 3-Clause "New" or "Revised" License
0 stars 6 forks source link

Upgrade Google analytics to GA4 #349

Closed jasonwebber-bl closed 2 years ago

jasonwebber-bl commented 2 years ago

https://support.google.com/analytics/answer/11583528

anjackson commented 2 years ago

This search shows where all the older Analytics integrations are: https://github.com/search?q=org%3Aukwa+google-analytics&type=code

And this covers PyWB https://github.com/ukwa/ukwa-pywb/issues/86 (which uses a slightly newer version of the analytics code)

anjackson commented 2 years ago

BTW, in Google Analytics, I've set up a new http://www.webarchive.org.uk - GA4 'property' which we'll be able to move things to. It requires this tracking code:

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

  gtag('config', 'G-K5N6D6LKHP');
</script>
jasonwebber-bl commented 2 years ago

I've checked with the BL comms and web teams on how they are processing this transition. They plan to add GA4 in the autumn and run both systems together for 6 months (until the end of Mar 23) while they are setting up the new 'events' in GA4. I think we should do the same approach. This would ensure continuity of current stats until the end of the 2022 reporting period and give us time to set up a new system.

anjackson commented 2 years ago

Thanks @jasonwebber-bl that makes sense. So we should just add the new tracking code, so that both are active, rather than replacing one with the other.

jasonwebber-bl commented 2 years ago

Yes please. Setting up the events in the new GA4 will need some thinking about. I'm currently trying to learn what the possibilities are and it would be good to be able to test and try some of these.

anjackson commented 2 years ago

@min2ha it should just be a case of pasting and adding in the HTML fragment in https://github.com/ukwa/ukwa-ui/issues/349#issuecomment-1111030511 into the UKWA-UI codebase in the right place.

https://github.com/ukwa/ukwa-ui/blob/d464f71e2ac0b463863ef9d78d3d2523b6990394/src/main/webapp/WEB-INF/jsp/footer.jsp#L249

anjackson commented 2 years ago

As this is a very small and simple change, I've asked @min2ha to include it in the 1.4.2 release.

anjackson commented 2 years ago

Logged into Google Analytics and I can verify that the visits are coming through for UKWA-UI.