qlik-oss / core-website

Source code for the core.qlik.com website.
https://core.qlik.com
MIT License
16 stars 35 forks source link

Replace OOTB Google Analytics with Tag Manager #462

Closed peol closed 5 years ago

peol commented 5 years ago

Material for MKDocs supports what's called "classic google analytics" but we should move to "google analytics tag manager" instead. We need to override the MKDocs partial for analytics and use this script instead of the existing one:

<!-- 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-P7VJSX');</script>
<!-- End Google Tag Manager -->

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-P7VJSX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

GTM-P7VJSX here is the tracking code and should be fetched from the MKDocs config instead.

Resources:

https://squidfunk.github.io/mkdocs-material/getting-started/#google-analytics https://github.com/squidfunk/mkdocs-material/blob/65ab9fa0181a43e26b701df490fbdf4774b280af/src/partials/integrations/analytics.html#L42