Link to home
Start Free TrialLog in
Avatar of CAE5942
CAE5942

asked on

Location of Google Analytics code in Magento site

Hi everyone,

I have the following script on the pages of my site:

<script>
  (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-50223530-1', 'mysite.com');
  ga('send', 'pageview');

</script>

Open in new window


I've done a complete site search for the above script but cannot find it anywhere in my site files within my Magento built site. I wondered if anyone could tell me where this code being generated from?

Really appreciate any help.
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Couple of question... Where does it appear in the view source of the HTML documents?  How did you search  the site or site files - what search string, what libraries, etc?  I'm guessing it's part of a template document, but if we know more about what you've tried we may be better able to help figure it out.
Hi,

Google Analytics is by default provided with 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.

If you want to update the existing code, then follow this path : yourtheme/default/template/googleanalytics/ga.phtml

I hope it will be works for you.

Thanks & regards
Clark Kent
Avatar of CAE5942
CAE5942

ASKER

Thanks for the replies,

@Ray Paseur: The code I posted appears just before the closing head tag. There's also another Google Analytics code block just after the opening body tag and that one is being generated dynamically using the Magento Admin Panel at the path indicated by @Clark Kent. So the first block in the head tag is the one that I need to remove as I don't need it any more. I searched the site files both in my local site using Adobe Dreamweaver and I also searched the files on the remote server of the web host. I used UA-50223530-1 as the search string.

Is the above information helpful for you to assist further?
Hi gwh2,


Please check the Miscellaneous HTML file. Might be google analytic code in it.
Avatar of CAE5942

ASKER

Hi, can you let me know the path to the miscellaneous html file? I searched for miscellaneous.html using dreamweaver but there were no search results.
ASKER CERTIFIED SOLUTION
Avatar of Clark Kent
Clark Kent
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CAE5942

ASKER

@Clark Kent - thank you so much. That is where the code was found. I really appreciate your help.