Most of websites today are using GA to tracking and improving their website performance. and its also common technique to setup a goal which is useful too if you want to track specific activity on your website. like the most common example is to track a web form, when user submit that form, its called goal which we can call ‘contact’. Now in Google analytic how do we track this contact form? we used a technique from last many years that is to redirect user to a ‘thank-you’ page. when user enter data and hit submit button, that user will goes to our thank-you page and in GA we track this as goal. this used for couple of years until GA introduced events in GA, now we can track goals without leaving or refreshing page. sometime we come across a case when we can’t create thank-you page or we using AJAX and we don’t want to leave that page. so how do we setup a goal which will track events? this is what i am talking about.
Bellow are 6 easy steps to setup events in GA. i am using it for subscribe button.
1. Open up the profile you wish to set up the goal in.
2. Click the gear icon in the upper right corner of the Google Analytic interface.
3. Click the Goals tab.
4. Choose the Goal Set you wish to add the event to.
5. Name your goal and select the Event radio button.
6. Fill the details which requires as i did bellow.
In Category field put ‘subscribe’ and select “that matches” from drop-down
In Action field put ‘subscribe tracking’ and select “that matches ” from drop-down
and rest of two fields are optional, you can leave blank.
and now in you HTML code put following code in your submit button.
onClick="_gaq.push(['_trackEvent', 'subscribe', 'subscribe tracking',,, false]);"
for a submit button it will look like
<input id=”subscribe-button” class=”button” type=”submit” value=”Submit” onClick="_gaq.push(['_trackEvent', 'subscribe', 'subscribe tracking',,, false]);">
and that’s it. you have to wait for 24 to 48 hours to see if its tracking properly.