Installing google analytics

Discussion in 'WordPress' started by kahmed09, Sep 7, 2012.

  1. #1
    I have installed google analytics on my sites in the index page of wordpress, but it comes up with a header error.

    What can i do to get rid of the error, maybe my analytics is in the wrong place, where should i install it?

    do i have to put something like

    <head>

    nglrenlg'neg
    tg
    re
    gre
    g

    </head>
     
    kahmed09, Sep 7, 2012 IP
  2. Devtard

    Devtard Notable Member

    Messages:
    850
    Likes Received:
    133
    Best Answers:
    4
    Trophy Points:
    220
    #2
    Put the GA code before </head>. Don't edit any PHP code in your header.php.
     
    Devtard, Sep 7, 2012 IP
  3. RobinInTexas

    RobinInTexas Active Member

    Messages:
    217
    Likes Received:
    14
    Best Answers:
    2
    Trophy Points:
    65
    #3
    The easiest way to install the code is to use the [TABLE="width: 142"]
    [TR]
    [TD="width: 142"]WP Google Analytics[/TD]
    [/TR]
    [/TABLE]
    plugin
     
    RobinInTexas, Sep 11, 2012 IP
  4. xFire

    xFire Greenhorn

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #4
    Put the code at the bottom most of your template just before </body>. It should solve the problem.
     
    xFire, Sep 11, 2012 IP
  5. Devtard

    Devtard Notable Member

    Messages:
    850
    Likes Received:
    133
    Best Answers:
    4
    Trophy Points:
    220
    #5
    That's not the right position. GA codes should be placed before </head>.
     
    Devtard, Sep 11, 2012 IP
  6. pupul

    pupul Prominent Member

    Messages:
    1,737
    Likes Received:
    66
    Best Answers:
    2
    Trophy Points:
    340
    #6
    Use a plugin for Google analytics.
     
    pupul, Sep 11, 2012 IP
  7. xFire

    xFire Greenhorn

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #7
    Who said that ?
    Every script is basically better to place in the footer. Because it will be loaded after every other components loaded. It makes the website load much faster. Doesn't really matter where code is put it will achieve the same result.
    even if you put the google analytic inside the <body> it will be loaded fine.

    Obviously the best location to google analytic or other tracking code is before </body> tag. Because it will be loaded after everything else loaded.
     
    xFire, Sep 11, 2012 IP
  8. Devtard

    Devtard Notable Member

    Messages:
    850
    Likes Received:
    133
    Best Answers:
    4
    Trophy Points:
    220
    #8
    It is written here:
     
    Last edited: Sep 12, 2012
    Devtard, Sep 12, 2012 IP
  9. xFire

    xFire Greenhorn

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #9
    Yeah I get that, but whosaid that put the code on the footer is not the right thing to do?

    As I said before, doesn't really matter where you put the code it will still works. But in best practice it will be best to put it on the footer.
     
    xFire, Sep 12, 2012 IP
  10. Devtard

    Devtard Notable Member

    Messages:
    850
    Likes Received:
    133
    Best Answers:
    4
    Trophy Points:
    220
    #10
    Well, on the page I linked to is also this note, which explains why people should put the code to the <head> section:

     
    Devtard, Sep 12, 2012 IP
  11. xFire

    xFire Greenhorn

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #11
    it's also said that " It is customary to place JavaScript code in the <head> section"

    there you go. nobody , except you alone that said put the code on the footer is not the right thing to do.

    put the code on the footer is a perfectly right thing to do.

    the one who said that putting a script on the footer is not the right thing to do, doesn't really know how a JavaScript work.
     
    xFire, Sep 12, 2012 IP
  12. Devtard

    Devtard Notable Member

    Messages:
    850
    Likes Received:
    133
    Best Answers:
    4
    Trophy Points:
    220
    #12
    I am not an expert on this issue but I would stick to their recommendation. GA gives more accurate data then and I doubt that visitors would mind if pages with the tracking code before </head> would load 5 miliseconds slower than in the case when the code is placed before </body>.

    People who prefer fast loading of pages use browser addons like NoScript anyway. :)
     
    Devtard, Sep 12, 2012 IP
  13. yokowasis

    yokowasis Member

    Messages:
    141
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    #13
    Sure thing, it is just a matter of preference. Whether to put the code in the head or in the footer, or even in the body, all of it just work the same. The script will load and works fine. The only difference between them is the execution order. Nothing else. As long as the page fully loaded all of them give the same results.

    For people who got fast internet connection sure doesn't tell the difference. But for people who has slow internet connection (like me), sure can tell the difference. I often experience when visiting a website, on the status bar of my browser I "waiting for analytics.google.com" and left me staring a blank white page. Wouldn't it better to load the content of a website and load the script later, that way the visitor doesn't need to stare the blank white page.

    Most modern template has already doing this. Loading the main content first, and then loading the rest (images, slider, script, tracking code, jquery, etc).
     
    yokowasis, Sep 12, 2012 IP
  14. xFire

    xFire Greenhorn

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #14
    For me, no script is no way to go. Make the browsing faster by sacrificing browsing experience ? that's not definitely my style.
    Imagine, no script means, no ajax, no jquery, no javascript, no interactivy. It is so 1900.

    Back to GA. If you want to stick with the GA recommendation, it's your choice. I don't really care about what you do. I am not going to force or anyone out there to use my style.

    Back to the real problem, I am not agree with your statement here.
    Even GA never said that a footer is not the right position for the code.
     
    xFire, Sep 12, 2012 IP
  15. j4cko

    j4cko Banned

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Hi, its very hot interesting discuss. I just got a lot info and I liked to try all you suggest. Thank you guys.
     
    j4cko, Sep 13, 2012 IP
  16. kwl583

    kwl583 Greenhorn

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #16

    May be your opinion can solve his problem.
    I think you have suggested very well.
     
    kwl583, Sep 13, 2012 IP
  17. alishaceilava

    alishaceilava Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Put the code in the footer. That serves the same purpose unless, if there is any bloackage to the footer. Header is always recommended
     
    alishaceilava, Sep 14, 2012 IP
  18. TheCreator

    TheCreator Banned

    Messages:
    372
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #18
    Agree, put the code in the header is well recommended to make more reliable real time show result in google analytics. But putting the code in body or in footer is also OK. Make sure to also install and activate plugin named "Google Analytics for Wordpress". Last step is in the plugin, click settings, then in "Analytics Profile" part thick "Manally enter your UA code" (login to analytics.google.com then find your UA... code), then enter manually your UA code. Guaranteed work.
     
    TheCreator, Sep 15, 2012 IP
  19. ankurzen

    ankurzen Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    wp google analytics plugin worked fine for me........... :)
     
    ankurzen, Sep 16, 2012 IP
  20. Manishkhatri

    Manishkhatri Greenhorn

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #20
    Download this plugin from google or wordpress...

    [h=2]Google Analytics for WordPress[/h]
    it works fine
     
    Manishkhatri, Sep 16, 2012 IP