Google Analytics / Google Tag Manager in the <head>

Howdy! I've just set up Google Analytics and followed the set-up steps to add this code to the beginning of my head section of each page: <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-G8PTM5VMZW"></script> <script> window.dataLayer = window.dataLayer []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-G8PTM5VMZW'); </script> I've since set-up Google Tag manager, and asked me to add this code to the <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-K6FXLSWW');</script> <!-- End Google Tag Manager --> My Question is Do I need both of these ? Can I remove the Google Analytics code and wil Google Tag manager still work and send data to GA ? Thanks!!
1 Reply
reddogg476
reddogg47610mo ago
Hi User9511. The setup videos explain how to configure the script tags for your HTML pages. They're throughout the setup tutorial: https://support.google.com/analytics/answer/9304153?hl=en&ref_topic=14088998&sjid=8927802455979436989-NC
[GA4] Set up Analytics for a website and/or app - Analytics Help
Discover how to set up Google Analytics for your website or app by creating a Google Analytics 4 property, adding a data stream, and adding your Google Analytics code.Do you have multiple websites and
Want results from more Discord servers?
Add your server