This post was last updated on

Recording visitor source / search term in web contact form

This post is now an archive and the information may no longer be accurate / relevant.

Ever wanted to know where your valuable website leads were coming from so you can identify your most profitable sources of web traffic and direct your online marketing spend accordingly? Well I just figured out how and I thought I’d be nice and share!!

This is a guide for those of us who run a non-transactional site (transactional/e-commerce sites will already be able to report these stats with online analytics as they can push the cart value out with the goal completion) that is built to generate leads that complete offline (most B2B organisations). If this describes you, then read on as you probably have great difficulty figuring out where the leads that do convert have come from (aside from them being ‘web leads’).

So what will you get? You will receive visitor source website (Google/Bing), the source content (web page at the referral website), visitor medium (organic/CPC), Campaign information (email/Ad traffic campaign reference (if set)) and finally the search terms the user used on google to find your site.
Why – if you can’t see the obvious benefit of tagging your leads with this information then why are you still reading this! In fact do it anyway and show your Boss – they will love you.

The data can just be emailed to your or inserted directly into your CRM system, such as SalesForce so that you can start reporting on the data straight away!

Crucially, if you use Google Analytics (and who doesn’t) the answer is already stored on your site (or, more accurately, your customers’ browser) by GA’s cookies – it’s just a case of getting that information into the contact form when it is submitted by the user.

Below is the code for doing this – it’s in two parts – first, the extra fields to add to your contact form, and the other is the script to add to you contact page. The script looks up the contents of the Google Analytics cookie on the user’s browser and then fills out the form with the appropriate data so that it get’s submitted with the contact form.

Here are the contact form fields to add to your site, as well as the inline CSS that will hide them from your visitors eyes:

<div style="visibility:hidden; display:none;">
 <input type="text" id="source" name="source" />
 <input type="text" id="medium" name="medium" />
 <input type="text" id="term" name="term" />
 <input type="text" id="content" name="content" />
 <input type="text" id="campaign" name="campaign" />
 </div>

For the script, well you can download that here: Web Contact/Lead Form Script. You just need to upload it to your site (put it in the js folder off of the root directory) and then link to it form the header of your page with this code:

<br><code><script type="text/javascript" src="/js/referrer.js"></script></code></p>

You may also need to add the jquery js script to the header of your site.

That’s it – now your contact form will send this visitor source information with your lead! Depending on your setup, you might also need to configure your form handling script, SalesForce Web-to-Lead form or CRM system to process this new data correctly, but now you can find out where your successful leads are coming from and stop wasting your online marketing spend on projects that don’t produce quality leads!

/end of post


Written by

Last updated

First published

in

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *