ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Google analytics with EE

May 08, 2008 12:15am

Subscribe [14]
  • #16 / May 12, 2008 5:11am

    Mark Bowen

    12637 posts

    Mark…Have a site that validates strict, put the Google code at the end before </body> and it no longer does…Arrrrg.
    For strict, doesn’t all javascript have to be in the head area?

    As far as I know it doesn’t matter where JS goes in a document whether it be STRICT or not but Google does say that the code needs to go just before the </body> tag and I did read right when they brought out GA that if it isn’t there then results and mileage may vary.

    I have also not had any problems with validation on STRICT sites when the code is at the bottom of the page.

    Best wishes,

    Mark

  • #17 / May 12, 2008 10:25am

    PXLated

    1800 posts

    simoncox/mark—Hmmm, sure doesn’t here…Client supplied Google code…
    —————
    Google-No - Validates Fine
    Google-Yes - 7 Errors, all in the Google code

    Edited: Removed links as problem was solved…see posts below.

  • #18 / May 12, 2008 10:55am

    Mark Bowen

    12637 posts

    Hi PX,

    What kind of errors are they as I think you may have posted the same URL twice above 😉 ?

    Also what does your GA code look like. This is mine and it works fine. have taken out some of the specifics although it can be viewed easily enough on the site it is on I suppose 😊

    <sc*ipt type="text/javasc*ipt">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    docu*ent.w*ite(unescape("<sc*ipt src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javasc*ipt'>"));
    </sc*ipt>
    <sc*ipt type="text/javasc*ipt">
    var pageTracker = _gat._getTracker("UA-XXXXXXX-1");
    pageTracker._initData();
    pageTracker._trackPageview();
    </sc*ipt>

    Don’t know if yours is anything like that? I checked out the links above but as I said before I don’t think you have the correct URL for one of them or you have taken out the GA code so I can’t really see what is going on 😉

    Best wishes,

    Mark

  • #19 / May 12, 2008 11:37am

    PXLated

    1800 posts

    Ooops - Corrected the links
    —————
    Looks like everything is the same as yours Mark except this… (unescape( ...in the third line.
    I presume I could use yours and just change the tracker # (UA-XXXXXXX-1)
    —————

    Edit-Add: The errors look like this…
    Line 632, Column 96: document type does not allow element “script” here.
    …ics.com/ga.js’ type=‘text/javascript’
    >\<\/script>” );

  • #20 / May 12, 2008 11:42am

    aftershock

    46 posts

    I had a similar problem with the new GA code. I was missing some traffic. This was due to the Google code not having the required code import. The reason I was getting some hits and not others was due to users having a cached version already from a previous site, the anlytics code would then be working.

    I added the following line above the GA code:

    <script type="text/javascript" src="http://www.google-analytics.com/ga.js">


    Also as Mark has said place it as the last code within your body tag.

  • #21 / May 12, 2008 11:49am

    Mark Bowen

    12637 posts

    Hi PX,

    You should be able to get the new tracking code if you log into the GA account and then copy it from the account settings. You will probably find that the code you have there is an older version although to tell the truth I don’t recognise it having been that although it may have been a while back. Anyway if you log in to the GA account then click on Edit under the settings column for the site that you need the code for then click on the Check Status link that should be on the top right of that section and at the bottom of the page that appears you should see Legacy Tracking Code and New Tracking Code.

    If you copy-paste the New Tracking Code into your site then your problems should hopefully all go away. Also this should definitely go just before the </body> tag.

    Hope that helps.

    Best wishes,

    Mark

  • #22 / May 12, 2008 12:03pm

    PXLated

    1800 posts

    Thanks Mark…I’ll have to get the Google login info from the client.

  • #23 / May 12, 2008 12:13pm

    Mark Bowen

    12637 posts

    No problems. Let us know how it goes although if your original code is pretty much the same except for needing to put in the numbers for your account then I would think that you can just place that in for now although possibly best to get it directly from Google just to make sure that they don’t have some really old GA account or something weird like that.

    Best wishes,

    Mark

  • #24 / May 12, 2008 12:27pm

    coolstuffchannel

    114 posts

    Aftershock,

    Interesting thought about the .js code being cached.  I will try that code on one area of my site to see if I notice any changes.  Now here’s a question, I have the following code to deliver multiple pages for each article.  Since there is really only one template for all of the pages, am I losing out on traffic?  I’ve noticed that some of the subsequent pages show in GA results but hardly any.  It is a little shocking that when there’s a multiple page article that most of the time folks don’t click on past the first page, wonder if there’s an issue here….


    {if segment_4 == "" OR segment_4 == 'P0'}
    {image}
    {body}
    {/if}


    {multi_field="extended|page2|page3|page4|page5|page6|page7|page8|page9|page10"}
    <div class=“paginate”>
    {paginate}
    (Page {current_page} of {total_pages} pages for this article {pagination_links})
    {/paginate}</div>

  • #25 / May 12, 2008 3:26pm

    PXLated

    1800 posts

    Mark…Got the new code and all is well…Thanks!

  • #26 / May 12, 2008 3:46pm

    Mark Bowen

    12637 posts

    Mark…Got the new code and all is well…Thanks!

    No problem! 😉 Glad it’s all working now!! 😊

    Best wishes,

    Mark

  • #27 / May 13, 2008 6:24pm

    Jason McCallister

    255 posts

    The only reason Google says to place it at the end before the </body> tag is because of slow connections, you can place the script in the header and you will not suffer any results.

    Also Google notes a difference between “unique” visits and repeat. Just my 2.5 cents.

  • #28 / May 13, 2008 6:30pm

    Mark Bowen

    12637 posts

    Very good point. Had never seen this help document before but just what I had read about peoples usage of it.

    Nice catch WTHIGO.

    Best wishes,

    Mark

  • #29 / May 13, 2008 6:35pm

    Jason McCallister

    255 posts

    I was going to post the help doc, but i won’t lie… I was lazy and I’m on break from a lab in a CISCO class so I don’t have my links. Thanks for picking up my slack, err i mean looking it up!

  • #30 / May 13, 2008 6:59pm

    Simon Cox

    405 posts

    That does not make sense - I think Google have that back to front. I would think the reason for it to be at the bottom of the page is so that the page loads fully before the hit is counted. If you have the script in the top of the page and someone has a bad connection and keeps reloading the page because only a bit of it shows then you are going to get a hit each time - which is a false reading because that person did not see your whole page.

    Which brings me back to coolstuffchannels 50% difference problem. If you have the GA tag in the bottom of the page you should get a more accurate reading unless your page doesn’t fully load properly - maybe there is a call out to a script on a different server, like a blogroll or something,that does not connect. That would explain the difference in GA and server hits.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases