Google Analytics (Google Analytics) is not just a traffic statistics tool, you can also use it to measure the effectiveness of advertising campaigns, tracking how far users to the desired page flow (from the click Ads to the shopping cart to the checkout page), and based on the user's information to set the browser and language environment support.
But none of this is what our developers need. Today I'm going to introduce you to a very different technique for tracking JavaScript errors through custom events. Let's take a look at how to implement error checking:
Tracks basic JavaScript error messages
window.addeventlistener (' Error ', function (e) {
_gaq.push ([
' _trackevent '),
' JavaScript Error ',
e.message,
e.filename + ': ' + E.lineno,
true
] ';
Trace AJAX error messages (JQuery API)
$ (document). Ajaxerror (function (e, request, settings) {
_gaq.push ([
' _ Trackevent ',
' Ajax error ',
Settings.url,
e.result,
true
];
};
Now, when you go into Google Analytics, you can see information about custom events while viewing other site statistics. Of course, you will tell marketers that these are not real mistakes, that is the function (laugh), that's another story. View error Reports
To have this function, first make sure that you have a Google Analytics account, check the steps: login to Google Analytics; Navigate the navigation panel on the left to find the behavior ; Click the event to view the overview;
There will be exceptions under the event category, click on the Event tab in the interface, click the dimension filter, and then you can see all the error messages that are tracked;
Custom Error Reporting
Google Analytics provides a powerful reporting customization feature, and you can customize error reporting to track information such as the operating system, browsers, and versions that generated the error. Setup steps: Find the custom feature, next to the Report tab; Click New Custom report; Generate Information = error tracking ; report Content => name = JavaScript error ; metr IC Group = all events ; dimension structure => event classification > operating system > Browser > Browser version > Event label; click Save;