WordPress.org

Ready to get started?Download WordPress

Forums

Where to insert Google Analytic tracking code (8 posts)

  1. Exitspeed
    Member
    Posted 5 years ago #

    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 autoilluminati.com

    Andy help would be greatly appreciated.

    Thank you
    Mel

  2. iridiax
    Member
    Posted 5 years ago #

    Put it in your theme's footer.php.

  3. Exitspeed
    Member
    Posted 5 years ago #

    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 + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    var pageTracker = _gat._getTracker("UA-1234567-1");
    pageTracker._trackPageview();
    </script>
    </body>
    </html>

  4. fubidoubidou
    Member
    Posted 5 years ago #

    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?

    Peter

  5. ericleeclark
    Member
    Posted 5 years ago #

    Exitspeed,

    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.

    Cheers!
    Eric

  6. fatsotomuscles
    Member
    Posted 5 years ago #

    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?

  7. GrandSlambert
    Member
    Posted 5 years ago #

    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.

  8. fatsotomuscles
    Member
    Posted 5 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.