Skip to content

Commit

Permalink
Merge pull request #1657 from alphagov/add-ga4
Browse files Browse the repository at this point in the history
Add GA4 analytics
  • Loading branch information
andy-collon authored Mar 26, 2024
2 parents e1d1bb8 + e621ef9 commit 4ac83fa
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ gem "uglifier"
gem "gds-api-adapters"
gem "gds-sso"
gem "govuk_admin_template"
gem "govuk_publishing_components"
gem "govuk_sidekiq"
gem "plek"

Expand Down
15 changes: 15 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,18 @@ GEM
sentry-rails (~> 5.3)
sentry-ruby (~> 5.3)
statsd-ruby (~> 1.5)
govuk_personalisation (0.16.0)
plek (>= 1.9.0)
rails (>= 6, < 8)
govuk_publishing_components (37.10.0)
govuk_app_config
govuk_personalisation (>= 0.7.0)
kramdown
plek
rails (>= 6)
rouge
sprockets (>= 3)
sprockets-rails
govuk_schemas (4.7.0)
json-schema (>= 2.8, < 4.2)
govuk_sidekiq (7.1.5)
Expand Down Expand Up @@ -222,6 +234,8 @@ GEM
activerecord
kaminari-core (= 1.2.2)
kaminari-core (1.2.2)
kramdown (2.4.0)
rexml
language_server-protocol (3.17.0.3)
link_header (0.0.8)
logstasher (2.1.5)
Expand Down Expand Up @@ -720,6 +734,7 @@ DEPENDENCIES
gds-sso
govuk_admin_template
govuk_app_config
govuk_publishing_components
govuk_schemas
govuk_sidekiq
govuk_test
Expand Down
6 changes: 6 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
//= require_self
//= require jquery.waypoints.min.js

//= require govuk_publishing_components/dependencies
//= require govuk_publishing_components/analytics

$(document).ready(function () {
$('.select2:not(.tagging_project):not(.bulk_tagger)').select2({ allowClear: true })
})

window.GOVUK.approveAllCookieTypes()
window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 })
24 changes: 24 additions & 0 deletions app/assets/javascripts/domain-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
window.GOVUK = window.GOVUK || {}
window.GOVUK.vars = window.GOVUK.vars || {}
window.GOVUK.vars.extraDomains = [
{
name: 'production',
domains: [
'content-tagger.publishing.service.gov.uk'
],
initialiseGA4: true,
id: 'GTM-W573BJPG',
gaProperty: 'UA-26179049-6'
},
{
name: 'integration',
domains: [
'content-tagger.integration.publishing.service.gov.uk'
],
initialiseGA4: true,
id: 'GTM-W573BJPG',
auth: '2jaYNm4QqCxqsb10EcYo5w',
preview: 'env-18',
gaProperty: 'UA-26179049-6'
}
]
4 changes: 4 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<% content_for :head do %>
<meta name="govuk:components_gem_version" content="<%= GovukPublishingComponents::VERSION %>" />
<%= javascript_include_tag "domain-config" %>
<%= javascript_include_tag "govuk_publishing_components/load-analytics" %>

<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag 'application' %>
<%= csrf_meta_tags %>
Expand Down
2 changes: 2 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Application < Rails::Application
# Configure denylisted tag types by publishing app
config.denylisted_tag_types = config_for(:denylisted_tag_types)

config.assets.css_compressor = nil

config.active_record.belongs_to_required_by_default = false

# Set asset path to be application specific so that we can put all GOV.UK
Expand Down

0 comments on commit 4ac83fa

Please sign in to comment.