How to create tracker like

I am thinking about trying out some more complicated statistics gathering (rather than just using webstats to track hits).

How would one create a script to do tracking where the swf itself would report to you (your server) information about the platform, browser, of the users machine as well as the domain and source where the swf is being viewed from (even if it is copied and played from a local machine) ?

I have looked at a bit and think it is great, but also think I would be better off learning how to do this myself than using their service…