” Event Tracking “(Event Tracker) is a new method available with Google Analytics Tracking API” ga.js “with the power to analyze the user’s interaction with our website , is achieved by Calling the elements that we want to analyze.
You to apply this technique with
- Anything Flash.
- Modules loaded through AJAX.
- Pages gadgets
- Download files
- Charging times
Charging times with Events Tracking
Of these options as you can see we are going to concentrate on the “loading times “.
In Event Tracking can measure time to load a page.
It’s very interesting because we can know what we need to optimize the pages’ to ‘and in which the charging time should be shorter.
To estimate the time of loading of a page we will do from beginning to end of the html page with the
difference is that we get the pass to the call _trackEvent ().
Google Analytics Tracking API
var begin = new Date ();
Start Begin.getTime var = ();
[... Content of the page ...]
var gaJsHost = (( “https” == document.location.protocol)? “htpps: / / ssl.”: “http://”);
var gaJsHost = (( "https:" == document.location.protocol)? "https: / / ssl.": "http://www.");
var pageTracker = _gat._getTracker ( "UA-xxxxxx-x");
And now comes the time to create an object Event Tracker as the "Page Load";
In the following manner:
var loadTracker = pageTracker._createEventTracker ( 'Page Load');
var end = new Date ();
Stope End.getTime var = ():
var timeElapse = Stop-Start: / / saved in milliseconds
loadTracker._trackEvent ( 'Load - Time', 'products / paginax.htm' timeElapse);