Replaced Google Analytic with Tag Manager

This commit is contained in:
Jakub Filo 2019-05-18 21:41:01 +02:00
parent c9ef63cce6
commit dbe27d3937
2 changed files with 13 additions and 15 deletions

View File

@ -18,20 +18,5 @@
<script> <script>
hljs.initHighlightingOnLoad(); hljs.initHighlightingOnLoad();
</script> </script>
{{ with .Site.Params.ga_api_key }}
<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');
</script>
{{ end }}
{{ with .Site.Params.mixpanel_api_key }}
<!-- start Mixpanel --><script type="text/javascript">(function(f,b){if(!b.__SV){var a,e,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.track_charge people.clear_charges people.delete_user".split(" ");
for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=f.createElement("script");a.type="text/javascript";a.async=!0;a.src="//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";e=f.getElementsByTagName("script")[0];e.parentNode.insertBefore(a,e)}})(document,window.mixpanel||[]);
mixpanel.init("{{ . }}");</script><!-- end Mixpanel -->
{{ end }}
</body> </body>
</html> </html>

View File

@ -46,8 +46,21 @@
}); });
</script> </script>
{{ end }} {{ end }}
{{ with .Site.Params.google_tag_manager }}
<script>
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
}
)(window,document,'script','dataLayer','GTM-5CXGJPJ');
</script>
{{ end }}
</head> </head>
<body> <body>
{{ with .Site.Params.google_tag_manager }}
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5CXGJPJ" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
{{ end }}
<header class="global-header" style="background-image:url({{ if isset .Params "image" }}{{ .Params.image }} {{ else }} /images/bg.svg {{ end }})"> <header class="global-header" style="background-image:url({{ if isset .Params "image" }}{{ .Params.image }} {{ else }} /images/bg.svg {{ end }})">
<section class="header-text"> <section class="header-text">
{{ partial "social.html" . }} {{ partial "social.html" . }}