Category Analytics

This is a sub-title placeholder, you can put your page description here.

How to track form submission conversion with Google Analytics event tracking

Tracking form submission conversion is among the challenging KPIs for most digital marketers. I’d like to discuss a few methods around form submission conversion tracking using Google Analytics.

Some times it’s not easy to create thank-you pages for all web forms. Due to technological complications, it’s not easy to integrate a thank-you page on some web forms to be able to track conversions and set our conversion goals based on page views on specific AJAX thank-you pages or Thank you prompts loading in layers. Custom web forms, Contact Form 7 plugin for WordPress and RSForms components for Joomla are among the forms that sometimes are not easy to track forms individually depending on the version and type of use.

 

 

What if you have 5-10 forms? You need to create 10 different thank-you pages then track each forms’ performance individually. Even so, then overall campaign conversion will be hard to determine. This is valid if you are not using multistage forms.

 

Here are two ways to do multiple form conversion tracking;

  1. Having one thank you page for all forms and track individual submissions through Google Analytics event tracking (Which is the purpose of this post)
  2. Create multiple Thank-You pages for each form and set conversion goals individually for each page.

First method is more precise, due to effective tracking of individual landing pages or multiple call to actions within the context of a page.

With Google Analytics’ event tracking using ga.js, you can easily track the following and have them inside your Analytics dashboard for a quick view;

  • Any Flash-driven element, like a Flash website, or a Flash Movie player
  • Embedded AJAX page elements
  • Page gadgets
  • File downloads
  • Load times for data
  • Form submissions

and a combination of creative ideas in between. First you need to make sure your website is properly tracked using Google Analytics. Be aware that there are two codes to track your website activity with Google Analytics, one is Analytics.js and the other is ga.js. This post is provides insight into using ga.js which is the recent Google Analytics code. You can easily update yours. Here is a link to make sure you are using the right approach;

 

Event Tracking

Tracking site activity with Google Analytics

If the name of your page tracker object is _gaq (Which is the case most of the time), and you want to track the form submission as an event. In order to do this, you will need to run the following JavaScript code when the submission event occurs, basically put in the on_submit event of your form submit button:

Click here for more info on Google developers support network.

_gaq.push(['_trackEvent', 'Contact Form', 'Submit']);

Here is the syntax to track an event,
_trackEvent(category, action, opt_label, opt_value, opt_noninteraction)

say when a link is clicked;

<a href="#" on-Click="_gaq.push(['_trackEvent', 'Videos',
'Play', 'Baby\'s First Birthday']);">Play</a>

for in depth information on event tracking please visit Event tracking – Web tracking ga.js

Here is the good part. Say you want to track form submissions. Here is a sample java scripts code snippet you need to insert in the page that holds the form code.

<script type=”text/j-avascript”>
function trackSubmissions(form, category, name, value) {
try {
_gaq.push([‘_trackEvent’, category, name, value]);
} catch(err){}
setTimeout(function() {
form.submit();
}, 100);
}
</script>

after inserting the code into the page, you can call this function on all forms within the page and inside the “onsubmit” event handler. Here is a sample code;

<form on-submit=”trackSubmissions(this, ‘category’, ‘name’, ‘value’); return false;”>
</form>
For more details regarding the code same, please visit Stackoverflow

In order to track your events, you need to know which elements within the syntax are required, and which elements are optional. Here is a list;
_trackEvent(category, action, opt_label, opt_value, opt_noninteraction)

  • category (required)
    The name you supply for the group of objects you want to track.
  • action (required)
    A string that is uniquely paired with each category, and commonly used to define the type of user interaction for the web object.
  • label (optional)
    An optional string to provide additional dimensions to the event data.
  • value (optional)
    An integer that you can use to provide numerical data about the user event.
  • non-interaction (optional)
    A boolean that when set to true, indicates that the event hit will not be used in bounce-rate calculation.

For wordpress specific projects using contact form 7 take a look at the On_Sent_Ok action hook method.

RSForm! Pro Conversion Goal Tracking with Google Analytics

 

RSForm! PRO is a robust form platform for Joomla that can handle most of the tough challenges of todays digital marketers. Tracking AJAX or responsive forms can sometimes be tricky, Specially conversion tracking and conversion goal setting in Google Analytics.

 

How RSForm Pro and Conversion Tracking Issue

RSForm! Pro loads the “thank you” message on the same page as the form itself which makes it hard to set conversion goals in Google Analytics due to the lack of a unique page as Thank-You page. Without a unique page, you can’t submit a unique URL as destination to your conversion goal settings in Google Analytics.

 

The workaround

There are 4 conversion tracking ways to do this. I’ll share the one that works all the time and is pretty robust. The other two is for you to experiment and try based on your website structure and limitations.

  1. Event Tracking – You can read this helpful article I wrote earlier on Conversion tracking through Events. It gives you insight how to set it up.
  2. Virtual Page views based on Google Analytics’ virtual pageview syntax and OnSubmit JavaScript Event_gaq.push([‘_trackPageview’, ‘/some-page’]);

    Then a specific thank you page can be created with Google Analytics code on it to track RSForm! Pro submissions by assigning that URL as the destination URL to Google Analytics Conversion goal

  3. Redirect to a Thank-You Page – A redirect can be used in the PHP script property to send traffic to a pre-designed ThankYou page. Here is the code; $mainframe->redirect(“http://example.com/thank-you.html”);
    For conditional tracking based on form input please visit RSJoomla here

 

 

Create a custom URL after the form is submitted by appending something to the end of URL. If the URL modification happens only after submission, the URL would be unique and having Google Analytics code on the page will record the submission.
Here I’d like to emphasize on the fact that tracking conversions through event tracking will alter the bounce rate stats. Just make sure what you are doing if you want to go the Event Tracking way.

Here I’ll explain the 3ed option. I’ve tried and verified that it works on a few client websites using Joomla 2.5+. The workaround would be to place a code like

$u .= ‘&Conversion=ServicePage1’;

in the $thankYouMessage. This is inside the Form -> Form properties -> Scripts -> PHP Scripts
You need to scroll to the bottom where you see $thankYouMessage and a box associated to it. This script is called after the form is submitted. You can do a lot of fun stuff with it and may be more customized script can be called to redirect to your Thank-you page of choice based on the form or page. Combinations are endless.

 

 

If you are using SEF components and have activated .htaccess to handle URLs then you might end up with a 404 error. You need to modify the code to;

$u .= ‘?Conversion=ServicePage1’;

In order to work. After completing this configuration all you need to do is to go to Google Analytics, setup your goal and insert the following destination URL ; http://www.example.com/servicepage.html?Conversion=ServicePage1 if you are utilizing .htacess to optimize URLs. Make sure Google Analytics code apears on all pages of your Joomla website.