Skip to content

Commit

Permalink
Update Hyrax to bring in bug fixes for GA4
Browse files Browse the repository at this point in the history
This commit will update the Hyrax revision to bring in the bug fixes for
Google Analytics 4 and also update the logic in Hyku's ga4 partial to
account for multitenancy more accurately.
  • Loading branch information
kirkkwang committed Feb 11, 2025
1 parent 4d91549 commit df8a46e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ GIT

GIT
remote: https://github.com/samvera/hyrax.git
revision: a726d9bc5b2ad6fcf40108bfa5c54feae7ba82cf
revision: 1be0b9cd7657691914607a11b11e726ce9f407c0
branch: main_before_rails_72
specs:
hyrax (5.0.3)
hyrax (5.0.4)
active-fedora (~> 14.0)
almond-rails (~> 0.1)
awesome_nested_set (~> 3.1)
Expand Down
15 changes: 10 additions & 5 deletions app/views/shared/_ga4.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<%# Override Hyrax 6.0.0 to use multiple analytics configs, one app wide one and one tenant override %>
<%# Override Hyrax v5.0.3 to use multiple analytics configs, one app wide one and one tenant override %>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= Hyrax::Analytics.config.analytics_id %>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '<%= Hyrax::Analytics.config.analytics_id %>');
<% if ENV.fetch('GOOGLE_ANALYTICS_ID', Hyrax::Analytics.config.analytics_id) != Hyrax::Analytics.config.analytics_id %>
gtag('config', '<%= ENV.fetch('GOOGLE_ANALYTICS_ID') %>');
<% if Hyrax::Analytics.config.analytics_id.present? %>
gtag('config', '<%= Hyrax::Analytics.config.analytics_id %>');
<% end %>
window.analytics = gtag;

<% if current_account.settings[:google_analytics_id].present? &&
current_account.settings[:google_analytics_id] != Hyrax::Analytics.config.analytics_id %>
gtag('config', '<%= current_account.settings[:google_analytics_id] %>');
<% end %>

window.analytics = gtag;
</script>
<meta name="analytics-provider" content="ga4">

0 comments on commit df8a46e

Please sign in to comment.