Support » Fixing WordPress » Installing google analytics

  • How do I install google analytics code?

    It says I must place it onto everypage I want to be tracked..

    where do I place it? In my index?

Viewing 15 replies - 1 through 15 (of 18 total)
  • You need to place the code only once in WP, place it just before the closing </head> tag.

    You’re best off using one of the many available plugins. I’ve had great success with Google Analyticator and Google Analytics for WordPress, but you can find many more here:

    I see all these pages I can edit…

    witch one of these pages is the one where I should place the code?

    Theme Functions
    Image Attachment Template
    Main Index Template
    Page Template
    Search Results
    Search Form
    Showcase Template Page Template
    Sidebar Template Page Template
    Single Post
    Tag Template
    Visual Editor RTL Stylesheet
    Visual Editor Stylesheet
    RTL Stylesheet

    Open the Header (header.php) and place the Google Analytics code just before the closing </head> tag. See guidelines HERE.

    But remember, when you update the theme, the code will be lost and you have to place it back again, unless you are using a child theme.


    I want to install google analytics code on my blog. I am not a geek. I don’t want to use a plugin as they say it slowers the site so if i prefer to do it myself. where to find the page to insert the code?
    thanks for your help.

    Please read my post above. It is done without any plugins.

    Hello Krishna,

    Before posting my message, I read the thread and opened your link. How can i enter in my source code page to place the code? Once i have placed it, will google analytics will track all my entire blog?

    Go to header.php (Dashboard > Editor) and locate </head> and place the Google Analytics code just before the closing head tag and save it.

    will google analytics will track all my entire blog?


    But, you will lose the code when you update the theme next time. You can replace it at the same place as soon as you update the theme.

    hello Krishna,

    Below, i have posted what is the html before the closing head tag. Do I have to place the code before /* =Header?



    #access a.assistive-text:active,
    #access a.assistive-text:focus {
    background: #eee;
    border-bottom: 1px solid #ddd;
    color: #1982d1;
    clip: auto !important;
    font-size: 12px;
    position: absolute;
    text-decoration: underline;
    top: 0;
    left: 7.6%;

    /* =Header

    As Krishna also mentioned this change will be erased the next time you update your theme so you really should consider using a plugin. One of the plugins by Erick Hitter at the top of this thread would do the trick and I highly doubt you will notice a speed difference in your site.

    Don’t you find the header.php?


    Sorry, i was in the wrong page. I copied pasted below what’s before and after the closing head tag and inserted the code. Is it right what I have done?
    Thanks in advance.

    * tag of your theme, or you will break many plugins, which
    	 * generally use this hook to add elements to <head> such
    	 * as styles, scripts, and meta tags.
    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-35437858-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);
    <body <?php body_class(); ?>>
    <div id="page" class="hfeed">

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser.]

    It looks OK and should work. You can verify at your Analytics account too.

    after the end of header.php file he can paste the script of any where

    Thank you all for your help. It works! I don’t know what would I do withouth this forum!

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Installing google analytics’ is closed to new replies.