Support » Fixing WordPress » Where to insert Google Analytic tracking code

  • I see that it says ‘Copy the following code block into every webpage you want to track immediately before the </body> tag. ‘

    I’m pretty new to actually adding code to the site. I assume I go to Theme Editor and I would add it somewhere in one of the templates or CSS.

    Site is

    Andy help would be greatly appreciated.

    Thank you

Viewing 7 replies - 1 through 7 (of 7 total)
  • Put it in your theme’s footer.php.

    Thanks. Like this?
    <div id=”page-bottom-margin”></div>

    <?php do_action(‘wp_footer’); ?>
    <script type=”text/javascript”>
    var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
    document.write(unescape(“%3Cscript src='” + gaJsHost + “’ type=’text/javascript’%3E%3C/script%3E”));
    <script type=”text/javascript”>
    var pageTracker = _gat._getTracker(“UA-1234567-1”);

    yup that’s pretty much what I have on my site.
    Don’t know if you’ve compromised your security by revealing your UA number to the world… maybe get this deleted just in case?



    Just a note… some themes have files with multiple <body> tags. This confused me at first, but some themes could use multiple footers, or otherwise be structured in a way where there are multiple. To be sure, just check through each *.php file and search for </body>. If you miss one, you won’t gather stats for that page.


    Would I have to insert my code in if I change to another theme? Or is it when I insert it once on one theme, and when I do change themes in a few months or so, I wouldn’t have to touch it again?

    Or make it easy on yourself and use the plugin called Google Analyticator. You enter just part of your code and you can tell it NOT to track when you, the admin, is on the site. Very handy plugin and you don’t have to edit any theme files to make this work.

    Thanks! Good information-I love the world wide web!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Where to insert Google Analytic tracking code’ is closed to new replies.