Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from gtag.js to Google Tag Manager Tag #3666

Open
1 of 4 tasks
jacobthill opened this issue Jan 28, 2025 · 0 comments
Open
1 of 4 tasks

Switch from gtag.js to Google Tag Manager Tag #3666

jacobthill opened this issue Jan 28, 2025 · 0 comments

Comments

@jacobthill
Copy link

jacobthill commented Jan 28, 2025

Amy Hodge needs to understand how often users are clicking on various buttons, etc. on the SDR site. In order to track these events, we need migrate from gtag.js to Google Tag Manager.

The tag currently installed (and installed on most/all of our sites)

  <script async src="https://www.googletagmanager.com/gtag/js?id=G-L3QLH9N3QH"></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());

    gtag('config', 'G-L3QLH9N3QH');
  </script>

is not a Google Tag Manager tag. It is a Global Site Tag (also called gtag.js or Google Tag). Google Tag Manager is similar but its actually a different system for managing tags. We don’t have Google Tag Manager set up on any sites (except DLME because QNL pushed for us to do so). The key differences are GTM allows you to manage all of your tags (not only Google tags), helps you keep them all organized in containers, and give you a lot more power to create custom tags for tracking events without code changes.

Here are some instructions for migrating to minimize gaps in data collection which are outlined below

  • Install the Tag Manager code on your site (devs): follow the instructions below (1 and 2)
  • Add Events and Variables (GA service manager)
  • Configure tags and their associated triggers in Tag Manager (GA service manager)
  • Final migration swap (devs and GA service manager): must be done in sync to minimize gaps in data
  1. Paste this code as high in the of the page as possible:
<!-- 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-WXBCLV2G');</script>
<!-- End Google Tag Manager -->
  1. Paste this code immediately after the opening tag:
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WXBCLV2G"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
@jacobthill jacobthill changed the title Add Google Tag Manager Tag Switch from gtag.js to Google Tag Manager Tag Jan 29, 2025
justinlittman added a commit that referenced this issue Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant