Use new Google Analytics gtag.js

This commit is contained in:
Rico Sta. Cruz 2017-09-24 02:33:02 +08:00
parent b5280175f0
commit 8de768dfb0
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 8 additions and 1 deletions

View File

@ -102,7 +102,14 @@
{% endif %}
{%comment%}<!-- google analytics -->{%endcomment%}
{% if site.data.google_analytics.enabled %}<script>if(~location.hostname.indexOf("{{site.data.google_analytics.hostname}}")){var _gaq=_gaq||[];_gaq.push(["_setAccount","{{ site.data.google_analytics.id }}"]);_gaq.push(["_trackPageview"]);(function(){var ga=document.createElement("script");ga.async=true;ga.src=("https:"==document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js";var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(ga,s)})()}</script>{% endif %}
{% if site.data.google_analytics.enabled %}
<script async src='https://www.googletagmanager.com/gtag/js?id={{ site.data.google_analytics.id }}'></script>
<script>
if(~location.hostname.indexOf('{{site.data.google_analytics.hostname}}')){
window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)};gtag('js',new Date());gtag('config','{{ site.data.google_analytics.id }}')
}
</script>
{% endif %}
<meta content='IE=edge' http-equiv='X-UA-Compatible'>
<meta content='width=device-width, initial-scale=1.0' name='viewport'>