1

I have 1.9.0 and the SEO lady wants me to put the following code into every page of the website in order so that she can work with Google Analytics. Is this already included in the Magento shopping cart? I activated this in SYSTEM - CONFIGURATION - SALES - GOOGLE API - GOOGLE ANALYTICS - it's asking for Type - Google Analytics or Universal Analytics and I put in the Account number. I read somewhere that 1.9.0 only has Universal Analytics working and 1.9.1 only has Google Analytics working - is that correct?

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-52215891-1', 'auto'); ga('send', 'pageview');

2 Answers 2

1

Google Analytics is native to Magento, you don't need to add the code yourself. Just go to System > Configuration > Google API > Google Analytics, select the right type, specify your Account Number and you're good to go.

As mentioned above the GA code needs to be updated, you can directly update yourtheme/default/template/googleanalytics/ga.phtml. Don't put it in Miscellaneous HTML, if you have many store views, it's just repeating code for no reason.

0

I typically place the GA code into the footer template file. There is an option within the admin section, but for me the theme is easier to edit than worrying about Magento's code being proper for any future changes to either GA or Magento.

Edit: Another option is to wrap the code you have above in tags and place it in System >> Configuration >> Design >> Footer >> Miscellaneous HTML

2
  • Hi Amit - thank you for your suggestion! How do I 'wrap the code in tags'? Thanks again! :-*
    – Allysin
    May 15, 2015 at 16:53
  • And how would I use the 'option within the admin section'?
    – Allysin
    May 15, 2015 at 17:07

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.