sciencehistory / scihist_digicoll

Science History Institute Digital Collections
Other
11 stars 0 forks source link

update Google Analytics code to "Google Analytics 4" #1658

Closed jrochkind closed 1 year ago

jrochkind commented 2 years ago

I received this email, which I believe means we have to update our Google Analytics... it looks like by July 1 2023 (note 2023, a year away). I am assuming our GA use is still on "Universal Google Analytics". This may apply to website too.

I am not very familiar with Google Analytics. Following the docs it looks like most of this is done in the Google console. At some point you'll need the developers to update the code in the app (probably?), but first I think it needs to be set up in console.

Hopefully our custom Event tracking stuff won't have to change?

Google Analytics 4 is replacing Universal Analytics

Google Analytics 4 is our next-generation measurement solution, and is replacing Universal Analytics. On July 1, 2023, Universal Analytics properties will stop processing new hits. If you still rely on Universal Analytics, we recommend that you complete your move to Google Analytics 4.

SET UP GOOGLE ANALYTICS 4

Now's the time to create a new Google Analytics 4 property and ensure that your setup is complete. If you haven't started collecting data in your Google Analytics 4 property, you should do so now. This will allow you to gather the historical insights you need to measure your results over time when Universal Analytics stops processing hits. If you are already collecting the data you need in Google Analytics 4, you should ensure your remaining setup is complete.

You can continue to use and collect new data in your Universal Analytics properties until July 1, 2023. After that, you will be able to access your previously processed data in Universal Analytics for a period of at least six months. We know your data is important to you and we strongly encourage you to export your historical reports during this time.

In the coming months, we will provide a future date for when we will fully sunset Universal Analytics. On this sunset date, you will no longer be able to see your Universal Analytics reports in the Analytics interface or access your Universal Analytics data via the API.

If you have questions on successfully making the switch to Google Analytics 4, check out our Help Center resources.

jrochkind commented 2 years ago

I think we WILL have to migrate our custom events stuff too. How annoying.

https://support.google.com/analytics/topic/11091421

It may be an opportunity to consider moving to something else other than Google Analytics, perhaps something without the privacy implications?

Although as long as main institute website is using Google Analytics, we should probably use the same thing as them, for consistency across the institution, fewer tools for staff to learn etc.

jrochkind commented 2 years ago

On the tech side, it looks like moving to "Google Analytics 4" will require us using "gtag.js or another tag management system".

If your current implementation of Universal Analytics uses on-page calls to analytics.js, you will also need to add gtag.js or Google Tag Manager (or another tag management system) to your pages so you can begin sending data to Google Analytics 4 as well (via connected site tags or via Google Analytics 4 tagging).

In general, you can't use the analytics.js library to send data to a Google Analytics 4 property. You can, however, use the Collect Universal Analytics events feature in your GA4 property to send analytics.js event, timing, and exception hits to a Google Analytics 4 property. Learn more

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

We do currently use analytics.js. https://github.com/sciencehistory/scihist_digicoll/blob/8f171db4444f4702cbfe98184bb506c73bd18a4b/app/views/layouts/_google_analytics.html.erb#L14

Hacker News seems to be less than enthused about the migration process and installation process for GA4 too. https://news.ycombinator.com/item?id=30706829

I find this whole thing very annoying, and am definitely interested in investigating alternatives to google analytics -- what we do with it is pretty simple, and we might find something else easier to use on both console and tech sides, it might also be less privacy invasive to our users.

apinkney0696 commented 2 years ago

Copying my correspondence with Clare here:

Hi Clare!

I think I remember you setting up my access to Google Analytics for the digital collections website. Are you the account administrator? I have an alert that our Google Analytics property must be updated from Universal Analytics to Google Analytics 4. https://support.google.com/analytics/answer/9744165?hl=en&utm_id=ad

I'm not exactly sure what this means, but when I try to follow the prompts to learn more and update the system, it tells me I need account administrator privileges to make any changes. https://analytics.google.com/analytics/web/?authuser=1#/a326869w144740760p168958592/admin/ga4-setup-assistant

This is not a high priority at the moment since we have until July 2023 to switch to the new property, but I wanted to ask early in case it was a lot of work or if we need to start considering alternative analytics systems.

Thank you! Best, Annabel


Hi Annabel,

Thanks so much for asking! Sciencehistory.org is facing the same thing, but we haven’t done it already because our Drupal 7 CMS can’t easily support it. So we’ll do it for the new site.

To do it I’ll need to make a new property for you. It’s telling me that you will have to re-tag the digital collections site. I think you could start anytime you’re ready!

That said, it’s going to be a pain to make reports that include old and new analytics because, as their support page says:

The GA4 Setup Assistant wizard does not backfill your new GA4 property with historical data. Your GA4 property only collects data going forward. To see historical data, use the reports in your Universal Analytics property.

For that reason you might want to plan it for a sensible switch date, maybe the first of a calendar month? I believe you would want to run the old UA and the new GA4 concurrently which might make the cutoff easier. Then in July 2023 you can clean out the old UA one.

Let me know what you think! I can create the new GA4 property anytime. Thanks Clare


Hi!

I just misspoke one thing. The property is ready because one of the GA4 advantages is not necessarily needing different properties for different subdomains. But the backfill issue still holds :-/

jrochkind commented 2 years ago

Some simple/cheap alternatives. The first two, plausible and matomo, are fairly popular. The others not sure. Couldn't find Clare's account to tag her here!

Some of these have "free" tiers which may or may not work for us, but they are all affordably priced, maybe $20-$100/month. None of them do nearly as much as Google Analytics, but we aren't using most of what Google Analytics offers, I think something simpler and easier to use that does what we need may be an advantage. The reviews I've seen of GA4 is that it is even more complex/hard to use than the GA we are used to.

Along with avoiding compromising patron privacy with google. Some of these services don't use cookies or otherwise track users, and thus could even allow us to get rid of that cookie warning banner.