• 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?

    samurailabs.cc/MissionControl/

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: http://wordpress.org/extend/plugins/search.php?q=google+analytics.

    Thread Starter samuraicc

    (@samuraicc)

    I see all these pages I can edit…

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

    Footer
    (footer.php)
    Theme Functions
    (functions.php)
    Header
    (header.php)
    Image Attachment Template
    (image.php)
    theme-options.php
    widgets.php
    Main Index Template
    (index.php)
    Page Template
    (page.php)
    Search Results
    (search.php)
    Search Form
    (searchform.php)
    Showcase Template Page Template
    (showcase.php)
    sidebar-footer.php
    Sidebar Template Page Template
    (sidebar-page.php)
    Sidebar
    (sidebar.php)
    Single Post
    (single.php)
    Tag Template
    (tag.php)
    Styles
    Stylesheet
    (style.css)
    Visual Editor RTL Stylesheet
    (editor-style-rtl.css)
    Visual Editor Stylesheet
    (editor-style.css)
    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.

    Hello,

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

    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?
    Emmanuelle

    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?

    Yes.

    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?

    Thanks

    Emmanuelle

    #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?

    Hello,

    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.
    Cheers,
    Emmanuelle

    * 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.
    	 */
    	wp_head();
    ?>
    <script type="text/javascript">
    
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-35437858-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>
    </head>
    
    <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!
    Cheers,
    Emmanuelle

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