Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Google Tag Manager Script Rate Topic   - - - - -

 
  • philr
  • Junior Member
  • Members
  • Join Date: 19-Oct 10
  • 23 posts

Posted 08 March 2019 - 11:43 PM #1

I am having an issue trying to get a Google Tag Manager script into the <head> section of my web pages. I have inserted the code into the file:

 

/my_changes/hooks/index/scripts.post.tpl

 

As recommended in other posts but it does not show in the source code. I have tried both with and without {literal}. I have also tried to install it in the "default" layout in the custom HTML code box as also suggested but the code just disappears when I hit "save".

 

Any direction would be appreciated.

 

 



 
  • philr
  • Junior Member
  • Members
  • Join Date: 19-Oct 10
  • 23 posts

Posted 09 March 2019 - 07:42 PM #2

Just wanted to mention that I followed these instructions from another post and it shut down my site:

 

Hello! You can create a file [cscart_root]/design/themes/[your_theme]/templates/addons/my_changes/hooks/index/head_scripts.post.tpl in my_changes addon and put your code to it.

 

The code I am trying to add is:

 

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

  gtag('config', '');
</script>

 

 



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19687 posts

Posted 11 March 2019 - 05:42 AM #3

You can try our free module

 

https://www.ecom-lab...ger-add-on.html


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • tjordan
  • Junior Member
  • Members
  • Join Date: 06-Oct 08
  • 128 posts

Posted 23 April 2019 - 12:57 PM #4

We put it in a meta.override.tpl which for us has a bunch of opengraph, schema code, and stuff for the head section of the site. 

You need to place it inside literal tags or it breaks the store. And, include data-no-defer to make sure the tag stays at the top. Here's what ours looks like. And it works.

 

{literal}
<!-- Global site tag (gtag.js) - Google Ads: xxxxxxxxxx -->
<script async src="https://www.googleta...AW-xxxxxxxxxx" data-no-defer></script>
<script  data-no-defer>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'AW-xxxxxxxxxx');
</script>
{/literal}



 
  • grabbags
  • Senior Member
  • Members
  • Join Date: 14-Aug 07
  • 360 posts

Posted 13 July 2019 - 12:11 AM #5

Thank you! 

 

You can try our free module

 

https://www.ecom-lab...ger-add-on.html