Skip to content

Commit

Permalink
Layout: Adjust placement of ganalytics js
Browse files Browse the repository at this point in the history
The instructions from google are not clear and error-prone. Place the js within
the head, at the end, not after the head.

References #355
  • Loading branch information
ybakos committed Apr 3, 2024
1 parent fa529b2 commit 713189b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
= javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
= javascript_importmap_tags
/ Google tag (gtag.js) should be after head.
%script{ src: "https://www.googletagmanager.com/gtag/js?id=G-PTHXK9D0S0"}
:javascript
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-PTHXK9D0S0');
%script{ src: "https://www.googletagmanager.com/gtag/js?id=G-PTHXK9D0S0"}
:javascript
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-PTHXK9D0S0');
%body{class: "#{controller.action_name}"}
= include_gon(:init => true)
= render 'layouts/nav'
Expand Down

0 comments on commit 713189b

Please sign in to comment.