Track HTML Forms Using Google Analytic Events

Lets say you have lot of forms and you want to track submission of those all forms,

its not always easy to track each one. but now GA made it easy for you. all you need to have a GA account and a profile for you website. you can have multiple forms and any other category in your website that is know is events for Google Analytic, you can easily track it using goals.

lets start with simple tracking.

<a href="idm.html" 
onclick="_gaq.push(['_trackEvent', 'downloads', 'IDM', 'tracking IMD downloads counts']);">
Download Internet download manager</a>

above tracking will be used for an click event for any link or button. _gaq.push function will put data to you GA account like its doing for other parameters. may be you have observed there are a lot parameters which actually GA passes data to show you a complete tracking profile.

bellow is a simple form called bio

<form action="submit.php" method="post" name="bio" onsubmit="_gaq.push(['_trackEvent', 'forms', 'bio', 'submitting bio form']);">
<input type="submit" value="submit" />
</form>

now look at the syntax of _gaq.push function, after _trackEvent next parameter is category which we have forms, because here we want to track lot forms, so we made a category forms. and then form name (event name) and the third parameter is somewhat details about our event. its optional , you can leave it blank, but you must need to put an empty string ”.

in this way you have a category and you want track lot forms , name each form and create a new goal for that form and fill details. you can also take help form my previous post how to fill details of goal

Setup Goals For Events In Google Analytics

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.

List Recent Posts from Specific Category – WordPress

You can list post from specific category by query_posts() function. it will take one or two parameters, one is category name and 2nd is no of post to show. like following code is showing exactly how it work.

<?php query_posts('category_name=internet&showposts=5'); ?>

and full code to show posts

<?php query_posts('category_name=internet&showposts=5'); ?>
<?php while (have_posts()) : the_post(); ?>
        <li><a href="<?php the_permalink(); ?>">
          <?php the_title(); ?>
          </a>  </li>
        <?php endwhile; ?>

and for normal code is here:

<?php while (have_posts()) : the_post(); ?>
 <li><a href="<?php the_permalink(); ?>">
 <?php the_title(); ?>
 </a> </li>
 <?php endwhile; ?>

query_posts() is a function which can also be used for custom post type. if you have some custom post type and want to show posts from , you can use this function. its take many parameters on the basis of which you can collect your required posts from db. in that case you will use to pass a list of array to this function and it will grab you required data.

query_posts( $args );

or you can pass directly to function.

query_posts( 'cat=3&year=2004&tag='phone'' );

in above code it will collect posts from category=3, year=2004 and tag=’phone’. so overall its amazing function to grab custom data from WordPress and can reduce your hurdle many times.

Google Is Now Much More Careful About Identity And Real Names

After Facebook now Google is also becoming more restrict to about real names on internet.  and about Google it is said to be true , that Google is taking more care than Facebook regarding real names. these companies now using face-recognition softwares to recognize your photos on internet. everyone know Google already collected a huge amount of data about every person who is using internet or used.

May be mostly peoples don’t care but when they comes online every action is being tracked from BIG companies, but these companies have very solid reason for this, they are improving web through this tracking and showing relevant ads to relevant peoples.

i can bet for this, Google have a very large amount of data for every person on the web and they are storing this on permanent basis. they are building profiles based on these information. and same situation here on Facebook. And now these companies are moving to next step, they want real names and information for every person who is using their services.

I am posting here Mr. Schmidt quote which is making things more clear to you :

“In the area of social media, we knew upfront 10 years ago that the Internet lacked essentially an accurate identity service. Im not here by the way talking about Facebook, the media gets confused when I talk about this. If you think about it, the Internet would be better if we had an accurate notion that you were a real person as opposed to a dog, or a fake person, or a spammer or what have you.

 

Here i am not talking about outcomes, this is just a informational post.