Skip to content

Commit

Permalink
Ensured GTM script is called if not dev environment
Browse files Browse the repository at this point in the history
  • Loading branch information
tahir-khalid committed Oct 16, 2024
1 parent af688ae commit 95bf3c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions app/controllers/concerns/cookies_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ def set_analytics_cookies(accept_analytics_cookies)
cookies[:accept_analytics_cookies] = { value: accept_analytics_cookies, expires: 1.year.from_now }
cookies[:cookie_preferences_set] = { value: accept_analytics_cookies, expires: 1.year.from_now }

if accept_analytics_cookies == true
cookies[:cookies_policy] = {
value: get_policy.to_json,
expires: 1.year.from_now,
httponly: true
}
end
cookies[:cookies_policy] = {
value: get_policy.to_json,
expires: 1.year.from_now,
httponly: true,
raw: true
}
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
<%= javascript_include_tag "application", type: "module", nonce: true %>
<%= stylesheet_link_tag "application" %>
<%= csrf_meta_tags %>
<% if Rails.env.production? && analytics_cookies_accepted? %>
<% unless Rails.env.development? %>
<%= render "shared/ga_head" %>
<% end %>
</head>
<body class="govuk-template__body app-body-class">
<% if Rails.env.production? && analytics_cookies_accepted? %>
<% unless Rails.env.development? %>
<%= render "shared/ga_body" %>
<% end %>
<%= javascript_tag nonce: true do -%>
Expand Down

0 comments on commit 95bf3c8

Please sign in to comment.