Forum Moderators: DixonJones

Message Too Old, No Replies

Moved GA code to head, now traffic is not reporting

         

travelin cat

5:18 pm on May 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



In order to track our GA across multiple domains, we have moved the tracking code to the header, and according to Google, this is acceptable and should work fine.

We are using the new js code which was working fine in the body tag, but now, even though Analytics is saying that our site is being tracked, we are not seeing any reporting data for over two days.

The Google Help people said to wait 24 hours for reporting and have not answered any other of my requests for help.

Anybody have any ideas as to why this is failing?

pageoneresults

5:36 pm on May 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is it possible you have other JavaScript that may "now" be interfering with the ga.js?

Hmmm, all this time working with GA and I've never thought about putting it in the <head>. I've had more than a few experiences where that code did not execute quick enough and if it were in the <head>, I think I'd have some performance issues to contend with, yes?

Have you tried this?

www.SiteScanGA.com

Google actually recommend the above tool in their help section.

travelin cat

8:13 pm on May 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



pageoneresults, our pages are mostly text so they load quickly, so I'm not concerned about load time. As far as www.SiteScanGA.com, I used them and they showed that their was no code on the page, even though it is plainly visible in the source of all pages.

About an hour ago I moved the code in front of some other javascript in the head in case that was the problem. Still waiting for the data to refresh to see if anything shows up.

g1smd

8:55 pm on May 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I feel fairly confident in saying that the code needs to be in the body somewhere.

Doesn't it pull an image from Google's server? If so, it must be in the body to work.

travelin cat

9:06 pm on May 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



g1smd,

This is from their site:

We generally recommend that you place the Google Analytics tracking code immediately before the closing </body> tag of your pages in order to avoid any issues with page loading delays for visitors with slow connection speeds. However, there are several situations where it might make more sense for you to install the code in the head:

* When using frames
* If your pages call _link or _linkByPost
* If you're using custom JavaScript functions that may conflict with the ga.js file

We had to do this because of item #2

pageoneresults

9:22 pm on May 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do you drop the JS directly in the <head> or are you creating an external .js file with the GA code? I'm interested in this as I've always strived to make sure that code sits right before the closing </body> element. It typically goes into the header as we use absolute positioning and the header is the last to load.

Receptional Andy

9:28 pm on May 9, 2008 (gmt 0)



It's a bit off topic (sorry!), but personally, I try to avoid third party javascript in the head of a webpage. Essentially, everything after that point relies on what happens with a script that contains content I *expect* to change periodically. Whether your site loads at all, what is visible, everything.

I'm a big fan of analytics, but getting a sale is much more important than tracking one ;)

travelin cat

9:31 pm on May 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



We did not create an external file. We used the exact code that was in the body and just moved it in to the head per their suggestion. I think the js is conflicting with other js we have in the head.

Google states that the js must execute before the _link call and that is why the said to put it in the head.

I was thinking about moving the code to the beginning of the <body> as it was not having a problem at the bottom of the <body> previously. Any thoughts on this?

travelin cat

9:34 pm on May 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I'm a big fan of analytics, but getting a sale is much more important than tracking one

Andy, I'm totally with you on that one. The reason we are doing this is to track sales as they leave our site and go to our partner's site. We have been depending on organic traffic and now want to know more about where the sales are coming from so that we can do some real grown up person advertising.