Permalink
Browse files

Disable google analytics on localhost to keep statistics more accurate.

  • Loading branch information...
james-otten committed Sep 9, 2018
1 parent 1bd3b1a commit 953019a0578d54f409c5e0d44ebcd00261d4a7fe
Showing with 9 additions and 7 deletions.
  1. +9 −7 layouts/partials/google_analytics.html
@@ -1,12 +1,14 @@
{{ with .Site.Params.googleAnalytics }}
<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','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ . }}', 'auto');
ga('send', 'pageview');
// Never report traffic that originates from local testing.
if (window.location.hostname != "localhost") {
(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');
ga('create', '{{ . }}', 'auto');
ga('send', 'pageview');
}
</script>
{{ end }}

0 comments on commit 953019a

Please sign in to comment.