HTML and CSS Reference
In-Depth Information
Tracking
jQuery
AJAX
requests
in
Google
Analytics
Steve Schwartz writes abou can use in the plugins.js that will allow you to
track jQuery AJAX requests at www.alfajango.com/blog/track-jquery-ajax-requests-
in-google-analytics . The following code snippet shows that script:
/*
* Log all jQuery AJAX requests to Google
Analytics
* See: http://www.alfajango.com/blog/
track-jquery-ajax-requests-in-google-analytics/
*/
if (typeof _gaq !== "undefined" && _gaq !==
null) {
$(document).ajaxSend(function(event, xhr,
settings){
_gaq.push(['_trackPageview', settings.url]);
});
}
Tracking JavaScript errors in Google Analytics
If you want to track JavaScript errors on your page using Google Analytics, it is pos-
sible to do so with the following script, which you need to add after the Google Ana-
lytics variable _gaq has been defined in the index.html page:
(function(window){
var undefined,
link = function (href) {
var a = window.document.createElement('a');
a.href = href;
return a;
};
window.onerror = function (message, file, row) {
var host = link(file).hostname;
Search WWH ::




Custom Search