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.
精彩评论