Fixed a bug when the event fired on 404/403 page

The solution is to never fire the event if the page is in an erroneous state.