• I’ve been having a problem with the google analytics for wordpress plugin, it says in the settings by default it inserts the code into the header but when i check my header.php in editor in my theme it is not there!

    it is not in the footer either.. where could it be?

    the strange thing is that google analytics is working fine BUT i am not sure if it will track every page.

    i understand normally it should be in </head> or around there for the header and </body> in the footer.. where on earth is this google analytics code then?

    and will this have an impact on the tracking if i do not know where it is?

Viewing 6 replies - 1 through 6 (of 6 total)
  • You won’t find it in the header.php

    Go to your site and in the browser, look at the source code, you should see the google analytics code in the header area.

    Thread Starter pete101

    (@pete101)

    yes i see it in the source code but people on here say that when you check your header.php or footer.php the google analytics for wordpress code should be written above </head> whether it’s inserted manually or via a plugin.

    what i am confused about is that the plugin basically inserts the code for you into the editor right?

    and if it hasn’t you’re suppose to add it manually yourself into the header or footer.

    why is it not showing in the header.php or footer.php when it’s been recommended to insert it there?

    surely once you save the changes the code should be written there.

    thanks for your help.

    Thread Starter pete101

    (@pete101)

    p.s. i have checked my source code and google analytics IS there but it is not in the header:

    script type=”text/javascript”>//<![CDATA[
    // Google Analytics for WordPress by Yoast v4.2.3 | https://yoast.com/wordpress/google-analytics/
    var _gaq = _gaq || [];
    _gaq.push([‘_setAccount’,’UA-xxxxxxxxxxx’]);
    _gaq.push([‘_trackPageview’]);
    (function() {
    var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
    ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl&#8217; : ‘https://www&#8217;) + ‘.google-analytics.com/ga.js’;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);

    this is where the plugin has written it in the source code.

    surely this is the wrong place?

    In the yoast plugin, there is the option to have the code in the header or the footer.

    Can you please provide a link to your site.

    Also if you want, you can just take the google analytics code, stick it in your header.php above the </head> tag and don’t need to use a plugin. I never do.

    Thread Starter pete101

    (@pete101)

    but what i mean is that it’s neither in the header nor footer yet it is working… i am really confused. you say the plugin lets you put it in the header or footer, but surely that means it’s been put in only 1 of those 2 places yet for some reason it has been put in neither otherwise i would have seen it in the header.php or the footer.php

    the thing i provided above for you is the source code where it is located about half way down well after the header inforamtion.

    could the plugin be putting the code somewhere else on my site?

    and if so would that affect my google analytics?

    Thread Starter pete101

    (@pete101)

    p.s.i cant provide my site yet it’s still under private launch but do you have any idea where it must have put the code?

    if i give you more of the source code would that help?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Google analytics for wordpress plugin, can't find the code in header or footer?’ is closed to new replies.