google_analytics_async.html (904B)
1 {{- $pc := .Site.Config.Privacy.GoogleAnalytics -}} 2 {{- if not $pc.Disable -}} 3 {{ with .Site.GoogleAnalytics }} 4 <script type="application/javascript"> 5 {{ template "__ga_js_set_doNotTrack" $ }} 6 if (!doNotTrack) { 7 window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date; 8 {{- if $pc.UseSessionStorage }} 9 if (window.sessionStorage) { 10 var GA_SESSION_STORAGE_KEY = 'ga:clientId'; 11 ga('create', '{{ . }}', { 12 'storage': 'none', 13 'clientId': sessionStorage.getItem(GA_SESSION_STORAGE_KEY) 14 }); 15 ga(function(tracker) { 16 sessionStorage.setItem(GA_SESSION_STORAGE_KEY, tracker.get('clientId')); 17 }); 18 } 19 {{ else }} 20 ga('create', '{{ . }}', 'auto'); 21 {{ end -}} 22 {{ if $pc.AnonymizeIP }}ga('set', 'anonymizeIp', true);{{ end }} 23 ga('send', 'pageview'); 24 } 25 </script> 26 <script async src='https://www.google-analytics.com/analytics.js'></script> 27 {{ end }} 28 {{- end -}}