开发者

JavaScript to PHP visitor trackers

Can anyone explain how javascript trackers (like the code that Google Analytics and Click, etc have you put on your page), work? I'd like to build my own and I'm fine with the PHP side of things, its just getting the data from a remote page with javascri开发者_StackOverflowpt that I'm unsure of.


They work by building and sending an image request with variables appended to the src="..." for the image, and then server-side scripting is used to parse the variables, and then a 1x1 transparent pixel output as the response. It is done this way so that if the user doesn't have javascript enabled, you can still have a hardcoded image inside noscript tags, passing the account info as a param. If you look at GA or yahoo or omniture code, you will see the img tag in noscript tags. The javascript basically does the exact same thing, only it appends more stuff to the image - extra data that can only be done with javascript (misc browser stuff you can't get from headers from the image request), as well as data from custom tracking.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜