cancel
Showing results for 
Search instead for 
Did you mean: 

Adding GTAG scripts for global and 2 specific actions

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Adding GTAG scripts for global and 2 specific actions

Hi,

 

Magento 2.2.3

 

Issue: Placing a 3rd party agency's tracking scripts on pages.

 

I am having an issue adding the flowing global script in admin between the <head></head> tags under Content>Configuration>Global>HTML Head>Scripts and Style Sheets to place the script on all pages:

 

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

  gtag('config', 'DC-xxxxxxx');
</script>
<!-- End of global snippet: Please do not remove -->

 

I put in there and cleared cache but it's not showing on www.stebbinsanderson.com. It works on my Magento 1.9x websites, but this is my first Magento 2 site that needed this. The reason I'm not using the building in GTM is I am not the owner of the GTM account as this is a 3rd party ad agency.

 

The other 2 scripts are a conversion and purchase script. What is the best approach to put these on the appropriate pages. Can they also be on all the pages or should I put them on specific theme pages? I am using the Porto theme.

 

Thanks in advance for any insight on this issue.

 

3 REPLIES 3

Re: Adding GTAG scripts for global and 2 specific actions

When you go to  Content>Configuration> how many rows you see there and in which you have uploaded that script? Please share screenshot. I think you are not putting this script in correct website's theme.

Re: Adding GTAG scripts for global and 2 specific actions

Here you go:

 

https://www.screencast.com/t/bAjjwl1L

 

I checked all the 3 and the script is in there as follows:

 

https://www.screencast.com/t/n3jasnjDDj

 

Thanks again as I'm stumped.

Re: Adding GTAG scripts for global and 2 specific actions

We have used the following Magento GTAG extension and it works really well for us.

 

https://www.scommerce-mage.com/magento-2-global-site-tag-js.html

 

Hope it helps.