Using Google Analytics without Javascript?

Is it possible to use the Google Analytics code on a website which does not support javascript or any server side scripting? (For example a profile page on a website which allows to use only HTML).

I have found out that analytics code can be used without using the javascript by calling the tracking image directly and send some data with it. I also found a couple of links but they use server side code also.


Technically, yes, since all you need to do is request __utm.gif from Google with a reasonable query string attached. This blog post on Google Analytics without javascript or cookies gives a good overview of what the __utm.gif request looks like.

Google Analytics actually has a pretty standard php implementation, but I take it you want to do this without any dynamic language at all - just one static tracking pixel to register a count of pageviews?

There are a lot of reasons why GA is not going to work 100% (and may not work at all) without a dynamic language. Primarily, GA depends on javascript (or a server side language) to set a user's utm cookies, which keep track of info about the visitor's source, and which help associate pageviews from a single visit.

Since you may just want to track a count of hits to a single page, we may be able to do away with this, although I am not completely sure that GA will not just filter our hits automatically with some sort of junk filter.

But, all that said, if you want to try this, I'd place a 1x1 image on the page with the following source:

http://www.google-analytics.com/__utm.gif?utmwv=5.1.7&utms=1&utmn=1894752493&utmhn=www.lunametrics.com&utmcs=UTF-8&utmsr=1280×1024&utmsc=24-bit&utmul=en-us&utmje=1&utmfl=10.3%20r183&utmdt=Tracking%20QR%20Codes%20with%20Google%20Analytics&utmhid=1681965357&utmr=http%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Dtracking%2Bqr%2Bcodes%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dorg.mozilla%3Aen-US%3Aofficial%26client%3Dfirefox-a&utmp=%2Fblog%2F2011%2F08%2F18%2Ftracking-qr-codes-google-anaytics%2F&utmac=UA-296882-1&utmcc=__utma%3D230887938.1463229748.1317737798.1317737798.1317737798.1%3B%2B__utmz%3D230887938.1317737798.1.1.utmcsr%3Dgoogle%7Cutmccn%3D(organic)%7Cutmcmd%3Dorganic%7Cutmctr%3Dtracking%2520qr%2520codes%3B&utmu=DC~

You'll need to adapt the source a little bit to fit the site you are tracking - see this LunaMetrics post for reference. At the very least, you'll need to change utmhn (hostname), utmr (referrer), utmp (current URI), and utmac (your GA account number).


Just point an image to the site with your account details, and you are good to go!

The format of the URL in the public service is:

http://nojsstats.appspot.com/your-google-analytics-user-account/your-website.com

For example:

http://nojsstats.appspot.com/UA-123456/your-website.com

Example (HTML code):

<img src="http://nojsstats.appspot.com/UA-123456/mywebsite.com" />

Example (BBCode):

[img]http://nojsstats.appspot.com/UA-123456/mywebsite.com[/img]

Example (CSS code):

body{
background: url("http://nojsstats.appspot.com/UA-123456/mywebsite.com");
}

Note:

If your website uses SSL, you have to point to our SSL version:
httpS://nojsstats.appspot.com/UA-123456/yourwebsite.com

Only use the SSL version if your website uses SSL. Credits: http://nojsstats.blogspot.in/

链接地址: http://www.djcxy.com/p/8392.html

上一篇: 为什么document.write被认为是“不好的做法”?

下一篇: 使用Google Analytics没有Javascript?