I have an account registration form where a user can select their account type. I have a goal set up in google analytics that has a signup funnel starting with the signup form and ending with the thank you page. I would also like to be able to track the number of account types in the goal or another goal altogether.
In the code below I have some radio buttons to choose the account type and then there is obviously a submit button after various other form fields.
My site is Magento/PHP.
<label><input type="radio" name="account_type" value="personal">Personal</label>
<label><input type="radio" name="account_type" value="business">Business</label>
[...]
<button role="button" title="Apply" type="submit">Apply</button>
I would be grateful for any advice. Thank you.
On your “thank you” page, in addition to the regular on-page code, you can also set a custom variable with the information. Alternatively, you can pop it when the visitor makes their selection (during click event) or on form submit (js callback function on submit button) but ideally since you will want to only pop it upon a successful form submission, the best way is to track it on the thank you page.
Example “thank you” page code:
Edit:
The above method is to set a custom variable with the desired info. This will introduce new dimensions and metrics to use in your reports. IMO the above is the best way to go about tracking this sort of thing.
However, in the comments below, greg mentioned that you might be asking how to track this as part of your goal. One thing you can do is invoke a _trackPageview on it, using a custom URL. For example (and this is just an example, to demonstrate the principle…ideally you will probably want to call this somewhere else, like in a wrapper function that grabs the form value…)
<button onclick="_gaq.push(['_trackPageview','/forms/accountType/[radio button value here]']);" role="button" title="Apply" type="submit">Apply</button>If you track it like this, then you will be able to include this virtual page name as a step in your current goal funnel. HOWEVER, NOTE that this method will increase your page views and screw with your other metrics; you will have to remember to exclude these page views from all your other reports!
Another alternative is to track it as an event, and you can make a separate goal based off the event. Example:
_gaq.push(['_trackEvent', 'Forms', 'Account Type', '[radio button value here]']);You can put it in an onclick like the 2nd code example above, or you can put it on the “thank you” page, like in the 1st code example above (I suggest putting it on the thank you page).