Viewing 15 replies - 1 through 15 (of 17 total)
  • Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    It shouldn’t be appearing in the body.
    What is the URL of your website?

    Thread Starter alistairgd

    (@alistairgd)

    Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    It’s being output in your theme’s footer function.
    With the new tracking code, it can actually be placed anywere. However, with the next update that comes out this week, we may move it back to the head.

    Thread Starter alistairgd

    (@alistairgd)

    According to Google it goes in one place, before the closing head tag.

    This is what puts me off using plugins for SEO, you have to check they are complying with good practice, which means you’re usually better off doing it yourself in the first place.

    Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    It can go anywhere.

    How can I change it? I can’t get Google analytics to work, and I think this is the problem. I can’t find anything else wrong.

    Can I just remove my Google Anaytics account number from ‘All In One SEO’ settings, then add the Google Analytics code to my header.php manually?

    Or will that confuse the plugin? Thanks.

    Stupid question: Why move it back to the head?

    Why move it to the head section? Try to verify Google Webmaster Tools with the code placed anywhere else and you’ll get this:

    “Verification failed for [URL removed] using the Google Analytics method (less than a minute ago). The Google Analytics tracking code on your site is in the wrong location. You can verify site ownership only with the asynchronous snippet placed in the <head> section of your home page.”

    Ever since Google updated Analytics they have told you to put the tracking code in the head section. The tracking will work with the code anywhere, but Google’s instructions are for it to be in the head section.

    @alistairgd: I found a hack to fix this for All In One SEO Pack. Go to your plugin editor and select All in One SEO Pack. The plugin file you want to edit is all-in-one-seo-pack/all_in_one_seo_pack.php

    You are looking for this line of code:

    ////analytics
    if($aioseop_options[‘aiosp_google_analytics_id’])
    add_action(‘wp_footer’, array($aiosp, ‘aiosp_google_analytics’));

    All you have to do is change wp_footer to wp_head and it fixes it for you. Something to keep in mind, you have to be sure that in your header.php you still have this code: <?php wp_head(); ?>

    Of course, if you are using this plugin it must be there else it won’t work. This just moves the analytics tracking code from the footer to the head section.

    Thread Starter alistairgd

    (@alistairgd)

    @daniel

    Thank you for taking the time to explain how to hack the plugin to be Google compliant, however I have decided to do all my on site SEO by hand.

    Plugins can save time, but the trade off is you never really know what they are doing under the hood, and you get caught it in upgrade chasing.

    So, by hand it is :o)

    Thanks anyway.

    @danieldeceuster Totally in agreement with you. The code snippet should be placed right before the closing head tag as stipulated by Google. I will not use this plugin because of that.

    Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    Google Analytic’s Asynchronous code can be in the head, and the rest of the stuff lower before </body>.
    All in One SEO Pack places Google’s tracking code in the <head>

    @michael Torbert I am glad to hear that. Have verified what you say so thanks for the clarification.

    What needs to be in the actual page templates? I am adding Google Analytic’s Asynchronous code in the form of analyticsTracking.php file and called by <?php include_once(“analyticsTracking.php”) ?> in the header.php file. But I’m still not seeing any results in my google analytics account.

    Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    mbyrne,

    You don’t need to do that. Just use All in One SEO Pack. That’s what this thread is for.

    What happens is the Google analytics ends up being displayed twice? Assuming that we never bothered removing the one that was integrated through the theme’s functions and using AIOSEO plugin?

    On my end, it was like that for the longest time and I had no issues, but reading this thread got me wondering if I should bother.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘[Plugin: All in One SEO Pack] Google analytics code is placed in wrong place’ is closed to new replies.