I was thinking perhaps it should be possible to track success rate of web-2-lead forms.

We have several forms on your site. My initial guess was attributed to a poor JavaScript validation, but after collecting several user-agent strings I wasn't able to find a patter.

My second guess is attributed to some problems on Salesforce side (we currently have workflows duplicating tasks), but before I start accusing Salesforce, I wan't to collect some data.

I think it should be possible to implement this with Google Analytics Event Tracking, not sure how. I do not want to dive into modifying CMS backend and fiddling with MySQL straight away, as some JavaScript would be much simpler to implement.

The simplest way would be to trigger and event when form is submitted and when users are returned to our website (aka after input type="hidden" name="retURL" value="http://www.site.com/form?sent=1).

Now, unless we submit the some user data to Analytics as well, we wouldn't be able to see much more data than conversion rate, but perhaps that's good for starters?


I have been playing with events a bit.

I have decided to send the tracking beacon upon successful form validation, as that would give me the most accurate data.

See the validation script below:

<script type="text/javascript">
    function checkForm() {
        var error = "";
        if($("#first_name").val()=="") { error+="- Enter your first name.\n";};
        if(error=="") {
            return true;
        } else {
            alert("Incorrect details:\n\n"+error)
            return false;

However, the event never appears in the Analytics dashboard (and it took me a while to realise I have previously excluded the office IP address from Analytics). However, running _gaq.push(..) from JavaScript console does work properly - the event appears nearly immediately in the dashboard.

I have seen something about setting timeout for the function?

Does anyone know what it means?

  • Can you be a bit more specific on what you're looking for? Just the rate of people filling the W2L form or something more in-depth?
    – Mike Chale
    Oct 21, 2013 at 13:28
  • W2L form fill success rate. Or to be more accurate, return-to-my-website-success rate. As a alternative method, I have seen someone doing asynchronous submits to no avail.
    – dzh
    Oct 29, 2013 at 17:30

6 Answers 6


On salesforce objects (lead in your case), create 5 custom fields for the GA source, medium, content, campaign, etc.

Add those to your w2l as hidden fields.

There are some good javascript functions written to parse the GA parameters. For example, https://stackoverflow.com/questions/8332970/extract-google-analytics-campaign-cookie-information-and-insert-into-inquiry-for

Now you can do salesforce regular reports to see conversion by different parameters, etc.

We also added the same fields to account so an account/opportunity report can reference them.

  • I am suspecting that web2lead facility is not working 100%, therefore inserting anything into SF would be useless.
    – dzh
    Oct 29, 2013 at 17:25

If the question was more along the lines of "how can I audit what's going into the W2L form vs what's in SF", try this:

Google analytics custom events are well-documented. Since the terms of use for GA forbid putting any personally identifying info into GA, you don't want so put emails or phone numbers or anything like that.

That said, you will capture time stamps for the events, which should be within seconds of the lead created timestamp. You could also use first/last initials so that you'll have something to compare against what shows up as leads in SF.


I think, perhaps a review of how the web2lead forms work will illustrate a nice clean way of doing this.

The web2lead forms are just a form, with a Salesforce url as the action and a POST method. Several fields are hidden, but essentially, these forms are decades old technology. Because of this, there's absolutely nothing saying that the form the user fills out be the form that is submitted to Salesforce. Forgive the crude diagraming here:

User submits Form -> POST to Your Server -> Your server auto-posts to Salesforce.

How does this accomplish what you're looking for? Well once you've sent the user submitted data to your server non-personally identifiable info can be submitted to GA. The key, is to ensure that both the user facing form, and the form on your server have identical names/id's

  • It posts directly to SF server, nothing to do with ours.
    – dzh
    Oct 29, 2013 at 17:26
  • @Dzh I realize that, I'm suggesting you ADD a intermediary step of posting to your own server first.
    – Kevin P
    Oct 29, 2013 at 17:31
  • Yes that is an option, however, as I mentioned initially, I would prefer to go thru easier path first.
    – dzh
    Oct 29, 2013 at 17:39

There's two approaches to this - track the conversions on the website side, and track the conversions from marketing source to closed won opportunity. I'll cover both.

You don't need to do anything with your website CMS to track the conversion rates, as long as you have Google Analytics. You'll likely want to setup a funnel. There will be at least two pages - the form page, and the 'thank you' page (specified by the retURL hidden field in the form) the visitors get directed to after submitting. The funnel will show you the drop off rate between the form and 'thank you' page. You can then run reports in Google Analytics to see what type of user is making it to the form page, and what kind submits vs dropping off. You can also make the form page a goal in of itself.

The challenge is, that once the form is submitted, it's like pouring all your leads into a giant bucket, and when they end up in the bucket you'll have no idea which one came from where. In Google Analytics, you'll be able to see (for example) that some leads came from Organic Search, some from Adwords, and some from a partner's blog. But once they get into Salesforce you won't know any of that.

This is where our app Daddy Analytics comes in. We'll capture all the information about the incoming visitors, and if/when they submit a form, we'll provide you that specific lead's origin, browsing history, first visit, whether they are organic / adwords / from an affiliate / etc.

This means that when you finally mark your sale Closed Won, and you get the money, you can answer the question, "What marketing activity led to this sale?" and when you add up all your month's / quarter's revenue, you can see where it came from, broken down to the search phrase, or adword keyword, or partner site.

Check out Daddy Analytics at http://daddyanalytics.com

  • That's pretty much what I implemented myself with 20 lines of JavaScript and a cookie. However, as Google making keyword encryption a standard, it is not big of use.
    – dzh
    Oct 29, 2013 at 17:27
  • Hi Dzh - the keyword encryption is only on organic, not paid search. So you get the search phrase and the keyword you bid on for SEM. As for the Javascript, that will likely not pull in first visit attribution, but otherwise does an excellent job as a free option. Apr 7, 2014 at 15:12

For the updated question (why the event isn't firing) please see the very helpful chrome extension called google analytics debug, or something like that.

It puts all the tracking beacon stuff into the console so you can see fields, values, etc that are being sent to GA

  • Know this one. I guess it's not Analytics issue, but more of JavaScript.
    – dzh
    Oct 30, 2013 at 9:00

There's one final thing to consider - if this is for Adwords, then you can use the free Google Offline Conversions tool. It only works for Adwords, and doesn't get the data into Salesforce but rather gets your conversions into Adwords. just search for "Google Offline Conversions Salesforce"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .