1
Magento 1.9.1
Porto theme

We are running an Adwords campaing and we were given the following code to place into the Magento shopping cart in order to track how successful the campaign is:

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

  gtag('config', 'UA-113694994-1'); 
</script>

I've tried putting this in the CMS home page,

  1. In the "Porto - Settings Panel" under Customization Settings --> Custom Style

  2. Under GENERAL --) DESIGN --) HTML HEAD --) Miscellaneous Scripts but it does not seem to work.

Where is the best place to place this code within Magento?

  • Check the answer & give feedback ;) – Raul Sanchez May 15 '18 at 6:04
0

Search for checkout/cart.phtml file (if I've understood your requirements right it should be placed only in cart page) in your app/design/frontend folder

You'll probably find more than one result, due to Magento theme fallback system https://www.classyllama.com/blog/depth-look-magento-theme-fallback

app/design/frontend/base/default/template/checkout/cart.phtml

app/design/frontend/XXX/XXX/template/checkout/cart.phtml

etc...

Locate which one is being rendered in your project, and place that Analytics JS code there

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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