Gearside Design

Tracking JavaScript Errors in Google Analytics

Since the primary implementation of Google Analytics is using JavaScript, how would you log events when users have JavaScript errors? This is an important question because if you see this event in your analytics action must be taken ASAP! If you’re not tracking errors, you are missing an important aspect of avoiding user frustration!

Setting this up is easy! There are only a couple rules— the script must be in it’s own <script> tag, and it must be placed after the Google Analytics code. This works best with Universal Analytics since the intended location of the tracking script is in the <head>.

Here is the script. ‘Category’ and ‘action’ can be changed as desired.