Skip to content

Commit

Permalink
refactor: Update Google Analytics code (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyzyz authored and LouisBarranqueiro committed Oct 11, 2018
1 parent 58a97e6 commit fb5830e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions layout/_partial/google-analytics.ejs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<% if (theme.google_analytics_id) { %>
<script type="text/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','//www.google-analytics.com/analytics.js','ga');
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= theme.google_analytics_id %>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
ga('create', '<%= theme.google_analytics_id %>', 'auto');
ga('send', 'pageview');
gtag('config', '<%= theme.google_analytics_id %>');
</script>
<% } %>

0 comments on commit fb5830e

Please sign in to comment.