We have a website that has a form on every page. We want to be able to track where the visitors are coming from and what keyword they are using to search(if coming from a search engine). We also want to know what page on our site they were on when they submitted the form. We do Google Pay Per Click and would like to know if they came from Google PPC or Google organic. If they came from Google Pay Per Click we would like a special internal code inserted into the form so we can track the sale. Also if possible we would like to know if they clicked on our Google Places link or our google organic link.
We want all this info inserted in the email that is sent when they submit their form. Our site is designed in php. I'm pretty sure what we need is some sort of cookie. I can actually install the cookie/script, I will will just need instructions.