Skip to content

Commit

Permalink
Do not send analysis information when page loading on locahost.
Browse files Browse the repository at this point in the history
  • Loading branch information
Duck1998 committed Oct 7, 2018
1 parent c1dc68d commit 908ee59
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,18 @@
var _gaId = '{{ site.ga_track_id }}';
var _gaDomain = '{{ site.ga_domain }}';

// Originial
(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', _gaId, _gaDomain);
ga('send', 'pageview');
// check whether running on localhost
var re = new RegExp('^(127.0.0.1|localhost)$')
if (!re.test(document.location.hostname)) {
// Originial
(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', _gaId, _gaDomain);
ga('send', 'pageview');
}
</script>
{% endif %}

Expand All @@ -173,13 +177,17 @@
// dynamic User by Hux
var _baId = '{{ site.ba_track_id }}';

// Originial
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?" + _baId;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
// check whether running on localhost
var re = new RegExp('^(127.0.0.1|localhost)$')
if (!re.test(document.location.hostname)) {
// Originial
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?" + _baId;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
}
</script>
{% endif %}

0 comments on commit 908ee59

Please sign in to comment.