Quantcast
Channel: Web Analytics India » Web Analytics
Viewing all articles
Browse latest Browse all 12

Tackle those Website Errors!

$
0
0

Often you will see errors on your website and will have no idea how to track them. Rather than sit and scratch your head, you should actually drill down and learn about how to track these errors.

Depending on whether you are using web server log files or page tags for collecting traffic data, there are different methods to capture errors:

 

 

 

 

 

 

1. Using log files as a data source

Web server log files record page requests with errors and successful page requests in the same way. But you can find out the difference by seeing the HTTP status code that is recorded along with the request in the log file.

Some of the most frequent HTTP protocol status codes are:

200 – Successful hit; the request was fulfilled

302 – Redirection. The data requested actually resides under a different URL

401 – Unauthorised request.

404 – The server has not found anything matching the given URL

503 – Service unavailable. The server is currently unable to handle the request

2. Using Page tags as a data source

Many hosted application vendors have custom error page codes that can be used to specifically capture errors, provided there is no specific JavaScript error on the page. This strategy usually requires that you have a custom error page (usually a 404 or “File Not Found” page that can be coded).

3. Client-Side JavaScript errors

Page tags cannot detect all types of errors directly because the problem does not by default trigger an event. Placing a page tag on a custom error page and passing the error message in a custom variable will record the incident for you and make the error information available to your reports.

One way to do this is to use page tags and error handlers in your scripts. For example, in JavaScript you can specify an ‘OnError’ handling function for your document. In OnError, you can send additional information via the page tag to a custom variable.

The following code can be used to build a list of client-side errors which can be passed to your web measurement page tag:

<SCRIPT>

‘Specify how JavaScript can handle any client-side errors’

Window.onerror = myOnError

‘Define arrays to capture the error messages’

msgArray =  new Array()

urlArray = new Array()

lnoArray = new Array ()

‘when an error is discovered, build an array of messages, urls and line numbers’

Function myOnError (msg, url, lno) {

msgArray[msgArray.length] = msg

urlArray[urlArray.length] = url

lnoArray[lnoArray.length] = lno

return true

}

‘Build a string that can be sent to the data collector’

Function sendErrors() {

Var ErrorList=””

For  (Var i=0; i < msgArray.length; i++) {

Errorlist = errorlist + urlArray[i] + ‘l’ + lnoArray[i] + ‘l’ + msgArray[i];

}

‘Call to the page tag/data collector goes here!’

}

</SCRIPT>

Depending then on how your particular web measurement application works, you’ll replace the ‘Call to the page tag/data collector goes here’ line with an image request (or whichever strategy your vendor recommends) that will send the string generated in the errorlist to a custom variable that can be examined later.

So here were some tips to deal with the most common types of errors. We hope this helped you. If you have any suggestions or want to share other types of error capturing techniques, please feel free to comment below.


Viewing all articles
Browse latest Browse all 12

Trending Articles