Skip to content

Commit

Permalink
Google Analytics 4
Browse files Browse the repository at this point in the history
  • Loading branch information
swrobel committed Mar 9, 2024
1 parent 61513ce commit 3ba7d63
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/views/layouts/application.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ html
= stylesheet_pack_tag 'application', media: 'all'
= javascript_pack_tag 'application'
- if ENV['GOOGLE_ANALYTICS_ID']
script async=true src='https://www.googletagmanager.com/gtag/js?id=#{ENV['GOOGLE_ANALYTICS_ID']}'
javascript:
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '#{ENV['GOOGLE_ANALYTICS_ID']}', 'auto');
ga('send', 'pageview');
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '#{ENV['GOOGLE_ANALYTICS_ID']}');
body
== yield

0 comments on commit 3ba7d63

Please sign in to comment.