CodeForPhilly / chime

COVID-19 Hospital Impact Model for Epidemics
https://codeforphilly.github.io/chime/
MIT License
205 stars 151 forks source link

Add GTM snippet #107

Closed themightychris closed 4 years ago

themightychris commented 4 years ago

Adding this GTM snippet will serve both for #78 and the need for frontend error capture, by letting us deploy an update to the frontend once and then manage adding/removing frontend embeds from Google's console. The price for this is letting Google collect all the data about all the things, but they were going to do that anyway if we're adding GA.

Add to top of <head>:

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

Add to top of <body>:

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

Next idea: https://stackoverflow.com/questions/19700871/how-to-inject-custom-content-via-nginx

We've confirmed that ingress-nginx has this module, and we already know we can inject arbitrary nginx location blocks via the Ingress definition...

mariekers commented 4 years ago

Would it be good to wait till the replatforming? As much as I dislike not collecting this data ASAP

themightychris commented 4 years ago

@mariekers we have a potential solution for injecting this at the kubernetes-level outside the application, which we can test out as soon as we have our pre-production cluster in order. If it works, then there's no benefit in waiting for the replatforming