New user data, including source

Does anyone know of a method or way to acquire analytical data to new users?

For example:
* Where did they come from before signing up? (An ad? Natural search result?)

- I assume capturing the source upon landing on the site, storing their data in a cookie and populating a hidden field with the cookie value would do this. Any other ideas?

* What is their IP address upon signup?