WordPress.org

Ready to get started?Download WordPress

Forums

Analytics code in head not working (12 posts)

  1. firefightertraininginc
    Member
    Posted 1 year ago #

    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 http://www.firefightertraininginc.com

  2. David Beja
    Member
    Posted 1 year ago #

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

  3. firefightertraininginc
    Member
    Posted 1 year ago #

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

  4. David Beja
    Member
    Posted 1 year ago #

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

  5. firefightertraininginc
    Member
    Posted 1 year ago #

    <?php
    /**
    * 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="http://gmpg.org/xfn/11">

    <script type="text/javascript">

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

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

    </script>

    <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(); ?>

    </head>

  6. firefightertraininginc
    Member
    Posted 1 year ago #

    See it about midway through?

  7. firefightertraininginc
    Member
    Posted 1 year ago #

    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!!!!

  8. David Beja
    Member
    Posted 1 year ago #

    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.

  9. ThorHammer
    Member
    Posted 1 year ago #

    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.

  10. firefightertraininginc
    Member
    Posted 1 year ago #

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

  11. David Beja
    Member
    Posted 1 year ago #

    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

  12. newbizassist
    Member
    Posted 8 months ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.