[SalesForce] Web-2-Lead submissions tracking with Google Analytics

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?

UPDATE:

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=="") {
            _gaq.push(['_trackEvent','Form','Submit','Newsletter'])
            return true;
        } else {
            alert("Incorrect details:\n\n"+error)
            return false;
        }
    }
</script>

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?

Best Answer

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.

Related Topic