GoogleChromeLabs / third-party-capital

A library that provides best practices for loading popular third-parties
Apache License 2.0
117 stars 8 forks source link

Add support for Google Tag Manager #41

Closed flashdesignory closed 10 months ago

flashdesignory commented 10 months ago

This pr assumes that we don't need to support the

for reference - default install code from head section:

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

default install code from body section:

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

feel free to tweak - this was just the initial setup - assuming we want it to be fairly close to the Google Analytics setup. @kara