One of my client have a Newsletter Signup Form; when users filled the fields and click the Submit Button the “thank you” message displays in the same page.
I want to track a click on a Submit Button of Newsletter Signup Form as a goal in Google Analytics. After bit research on that topic I learn that it can only be done by Event Tracking is a feature of Google Analytics. Idea is to track the submit event (onSubmit=) of the form.
It is useful for tracking actions on your website that don’t take the user to a new page [such as clicking play on a video player OR display thanks message on same page after submit button click (as per my client’s case) ].
The specification for the _trackEvent() method is:
pageTracker._trackEvent(_GAcategory, _GAaction, _GAlabel, _GAvalue);
Steps for track submit event in Google Analytics:
- Make sure you have implemented Google Analytics tracking code on your website.
- Use pageTracker._trackEvent(“Contact Forms”, “Newsletter Signup”); on onSubmit event.
So it might be:
onSubmit="pageTracker._trackEvent("Contact Forms", "Newsletter Signup");”
In this scenario, the reports for Events would display Contact Forms as the Category, Newsletter Signup as the Action.
- Log into Google Analytics Account.
- Click on the “Content Tab” found on the left sidebar.
- Click on “Event Tracking”, than Labels.
- Place the Google Analytics Tracking Code in your HTML ABOVE these (_trackEvent() method) calls so the JavaScript is already loaded. To be safe, put it just after the opening tag.
[NOTE:Place the Google Analytics Tracking Code in your HTML ABOVE these _trackEvent() method calls so the JavaScript is already loaded. To be safe, put it just after the opening tag.]