Skip to content

Commit

Permalink
Merge pull request #15 from CDL-Dryad/goog-analytics
Browse files Browse the repository at this point in the history
Updating Google analytics tag and only insert it if set in config
  • Loading branch information
ryscher authored Dec 3, 2019
2 parents 8954249 + 23e19f1 commit 542b38c
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<script>
(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');
<% unless APP_CONFIG.google_analytics_id.blank? %>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= APP_CONFIG.google_analytics_id %>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

ga('create', '<%= APP_CONFIG.google_analytics_id %>', 'auto');
ga('send', 'pageview');

</script>
gtag('config', '<%= APP_CONFIG.google_analytics_id %>');
</script>
<% end %>

0 comments on commit 542b38c

Please sign in to comment.