github.com/jbramsden/hugo@v0.47.1/docs/themes/gohugoioTheme/layouts/partials/gtag.html (about) 1 {{ with .Site.GoogleAnalytics }} 2 <script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script> 3 <script> 4 window.dataLayer = window.dataLayer || []; 5 function gtag(){dataLayer.push(arguments);} 6 gtag('js', new Date()); 7 8 {{ $site := $.Site.BaseURL | replaceRE "^https?://(www\\.)?([^/]+).*" "$2" }} 9 gtag('config', '{{ . }}', {'dimension1': '{{ $site }}', 'dimension2': '{{ getenv "BRANCH" }}'}); 10 11 /** 12 * Function that tracks a click on an outbound link in Analytics. 13 * Setting the transport method to 'beacon' lets the hit be sent 14 * using 'navigator.sendBeacon' in browser that support it. 15 */ 16 var trackOutboundLink = function(id, url) { 17 gtag('event', 'click', { 18 'event_category': 'outbound', 19 'event_label': id, 20 'transport_type': 'beacon', 21 'event_callback': function(){document.location = url;} 22 }); 23 } 24 25 </script> 26 {{ end }}