Support » Themes and Templates » Analytics code in head not working

  • firefightertraininginc


    I am using a woothemes theme wootique and am having trouble getting my google analytics code to be seen by the webmaster tools. Google analytics is tracking my site, but webmaster tools cant verify my site because it says the code is in the wrong spot. I put it in the header.php script prior to the </head> as instructed with no luck. Am I in the wrong script? There are other ways I can verify my site, but I would like to try to figure out why this isn’t working. website is

Viewing 11 replies - 1 through 11 (of 11 total)
  • Did you put the analytics code in the configuration page of your wootheme?
    Or directly in the code?

    Now the analytics code is at the bottom of the page before the </body> and not before the </head>.



    I put it in the header.php script. Is that the wrong place?

    No, that’s the right place.
    Are you sure you add the code to the right theme folder?

    I don’t see any analytics code inside the source code of your website in the head section, only in the bottom near the </body>.



    * Header Template
    * Here we setup all logic and HTML that is required for the header section of all screens.
    global $woo_options, $woocommerce;
    <!DOCTYPE html>
    <!–[if lt IE 7 ]> <html <?php language_attributes(); ?> class=”no-js ie6″> <![endif]–>
    <!–[if IE 7 ]> <html <?php language_attributes(); ?> class=”no-js ie7″> <![endif]–>
    <!–[if IE 8 ]> <html <?php language_attributes(); ?> class=”no-js ie8″> <![endif]–>
    <!–[if IE 9 ]> <html <?php language_attributes(); ?> class=”no-js ie9″> <![endif]–>
    <!–[if (gt IE 9)|!(IE)]><!–> <html <?php language_attributes(); ?> class=”no-js”> <!–<![endif]–>
    <head profile=”″>

    <script type=”text/javascript”>

    var _gaq = _gaq || [];
    _gaq.push([‘_setAccount’, ‘UA-36919862-1’]);

    (function() {
    var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
    ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘’;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);


    <title><?php woo_title(); ?></title>
    <?php woo_meta(); ?>

    <!– CSS –>

    <!– The main stylesheet –>
    <link rel=”stylesheet” href=”<?php echo get_stylesheet_directory_uri(); ?>/style.css”>

    <!– /CSS –>

    <link rel=”alternate” type=”application/rss+xml” title=”RSS 2.0″ href=”<?php $GLOBALS[‘feedurl’] = get_option(‘woo_feed_url’); if ( !empty($feedurl) ) { echo $feedurl; } else { echo get_bloginfo_rss(‘rss2_url’); } ?>” />

    <link rel=”pingback” href=”<?php bloginfo(‘pingback_url’); ?>” />

    <?php wp_head(); ?>
    <?php woo_head(); ?>




    See it about midway through?



    Figured it out. I left the code in the wootheme general settings and it must have been looking at that code. Thanks for the help and the quick replies!!!!

    great 🙂

    anyway, according to google you should put the code in the end of the head, just before the </head> so you have the best performance across all browsers with the other scripts.



    I was told that it is a good idea to put analytics code and other js calls in the footer in order not to halt the page load time.



    Thanks. I placed it where you recommended in the header!

    yes, ThorHammer, it’s generally the best place to put, but analytics code is asynchronous so there’s no performance issues if you put in the head, and in this way it increases the chances that the user is tracked before leaving the page.

    How to set up the web tracking code

    FYI, I have been trying for 2 days to get GoogleAnalytics to work in my WooTheme of WordPress. Until I found the code you had above, nothing worked. The code provided by Google when I set it up does not work. Your code did. Thank you! Of course, I did change the tracking number.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Analytics code in head not working’ is closed to new replies.