Justin from EpikOne wrote a great piece earlier this week explaining how to extract source, medium and campaign information from Google Analytics to insert in contact or lead forms. Essentially, it takes the data already stored about the visitor, and adds those values to hidden fields in the form. This means when your form submission comes through, it will contain valuable info about the visitor. Wouldn’t it be cool to get a lead email that looks like this:
Name: Joe Smith
Phone: 555-555-5555
email: joe@email.com
Notes: I’m interested in your product or service, please call me ASAP.
Visitor Source: Google search for ‘dallas widget maker’
Sure, you can always tell from the Google Analytics reports the conversion rate of each medium and source, but this allows to you tie each individual lead or contact form to a source. Why is this better? Well, all leads are not equal in value. If you do high volume on the Internet, you should probably know that 30% of your PPC leads turn into customers, but only 15% of your email leads do. Attaching this kind of tracking will enable you to make this next step calculation that would have otherwise been impossible.
So again, great job Justin! We went back and forth a few times in the comments about some ideas for improving the code (incidently, I had written the exact same program for my employer last week, but hadn’t published it). I definitely suggest implementing this on your lead forms if you use Google Analytics.
I’m glad to be able to go to PubCon this December in Las Vegas! It should be a great conference, with plenty to learn from the sessions, speakers, keynotes and after conference chats. Last year I got to attend, but was only sent for about 16 hours. The sole purpose for my attendance was to join the Meet the Google Engineers session, where my employer thought I would learn some grand secret to the Google algorithm (yeah, right). It was fun nevertheless, but I’m glad to get to go all week this year. I haven’t really been to a search conference since SES NY in 2005.
I think several of my former co-workers will be there as well, like Tony Wright and maybe Jeff Martin of cardsdirect.com. Maybe I can steal some of their money to gamble. 
I’ve used many website analytics tools in the past 5 years, but lately I’ve been doing a lot with Google Analytics. It’s free, and typically provides 90% of everything you could every want. One compalint I have, though, is that because there is a 6-12 hour delay in the reporting, configuring complex applications is difficult. Instead of tinkering, waiting a day, tinkering some more, wait another day, etc., I’ve learned to read server header requests to confirm that GA is working as expected.
If you use the Firefox browser, this is fairly easy to do. Download a simple plugin called LiveHTTPHeaders, and install it in the browser. Now you can view the header information in the browser’s sidebar by choosing View -> Sidebar -> LiveHTTPHeaders (or press ALT + L). Load a URL and you’ll likely see many fast requests go through the list, including images, CSS, javascript, etc.
To verify that a Google Analytics tag has executed properly, look for a like that starts like this:
http://www.google-analytics.com/__utm.gif…
This image request passes all of the necessary information on to Google’s servers, indicating that there was a page processed. There’s a ton of information on this line that you can decode if you so wish, including page URL, referrer, account ID, etc. If you scroll through the entire window and there is no mention of __utm.gif, guess what? The code didn’t exucute. That’s not good, but hey, at least you didn’t have to wait for 8 hours to find out, right?