3

I have google analytics in my website like this :

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxx-1"></script>
<script>
  window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}
gtag('js',new Date());gtag('config','UA-xxxxxxxx-1')
</script>

I placed it in the head tag

I want to add facebook pixel code in my website. I read some references and they said if it could be added via Google Tag Manager

So I install facebook pixel code in the google tag manager

I want to ask. Do I need to add the Google Tag Manager script again in the tag head on my website? Or is it not necessary? Because I already have google analytics on my website

2 Answers 2

6

you can leave the global site tag tracking code snippet on your site, just do not also configure tags for GA pageview tracking within GTM.

If it were me, I would remove the global site tag tracking code snippet and configure tags for GA tracking within the google tag manager container.

Bit of extra information:

Both Tag Manager and gtag.js perform similar functions:

Tag Manager is a tag management system that allows you to quickly and easily update tags on your website or mobile app from a web interface.

gtag.js is the JavaScript framework that is used to add Google tags directly to web pages.

https://support.google.com/tagmanager/answer/7582054?hl=en

11
  • How do I configure tags for tracking GA page views in GTM? Does it also need to add a script on my website? May 17, 2020 at 9:22
  • For example, I remove the global site tag tracking code snippet and configure tags for GA tracking within the google tag manager container. Will the analysis results from my website be lost or the analysis results still remain? I have installed Google Analytics in the last 2 years. I'm afraid it will disappear May 17, 2020 at 9:25
  • It will remain, you wont lose any of the historical data in GA, provided you don't delete any of the existing GA Views, the Property or the GA Account. Continue to use the existing GA Property for setting up your GA tracking tags inside GTM. You mentioned you installed fb pixel code in GTM, so I am assuming you have created a GTM account and created a GTM container and put the GTM container code on your site already and published the container with the fb pixel code in it.
    – Bronwyn V
    May 17, 2020 at 10:49
  • Once you have created and configured a pageview tag for univ. analytics in gtm, use the preview and debug mode to ensure it is firing ok.. then publish the container and remove the gtag.js tracking code snippet from your site. You will also have to setup any event tracking and so on within the GTM container too.
    – Bronwyn V
    May 17, 2020 at 10:50
  • So to solve this problem, I have to delete Global site tag (gtag.js) - Google Analytics and replace it with GTM container code? May 17, 2020 at 23:19
5

You need to add your Google Tag Manager code in your website.

Then, you have two options:

  1. Leave it, don't do anything else. Your Google Analytics code will remain as it is and FB Pixel will be added via Google Tag Manager.

  2. Alternatively, you can remove the code for Google Analytics from your website and add a tag in Google Tag Manager https://support.google.com/tagmanager/answer/6107124?hl=en (Recommended option for efficiency)

Do not mistake Google Tag Manager with the Global site tag you used to add Google Analytics, they are different things: https://developers.google.com/gtagjs

4
  • If I choose option 1, will I still add GTM container code on my website? May 18, 2020 at 6:44
  • Yes, even in option 1 you have to add the GTM code to your site to make the Facebook pixel fire.
    – WebElaine
    May 18, 2020 at 19:49
  • @Pablo Santamaria Okay. If I delete Global site tag (gtag.js) - Google Analytics and replace it with GTM container code, can the google analytics link analytics.google.com/analytics/web still be accessed? or do I have to access the analysis results via tagmanager.google.com? May 19, 2020 at 0:59
  • @SuccessMan that's right, you will still be able to access Analytics at analytics.google.com/analytics/web it doesn't change, that's where you read the reports. Option 2 in my response is only changing the way you add the script to your website that tracks the data that goes to those reports. I hope that makes sense. BTW WebElaine is totally right, you still need to add GTM, if you read my response it says to add GTM, then chose between option 1 and 2. May 19, 2020 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.