Q:

Track error 404 on google analytics with javascript

I want to track on google analytics the 404 errors.  Each time there is a 404 a specific part of my page has "404" string as content.  So, I create a Universal analytics tag. 

Then I create a custom javascript macro

function() {
       var viewcontainer = document.getElementsByClassName("view-container");
       var content = viewcontainer[0].childNodes[3].innerHTML;
       var error404 = parseInt(content);
//if there is an error page it returns 404, else it returns NaN
return error404;
}

The macro reads the contents of the part of my page on which the 404 should appear and returns it.  If it is an error it will return 404 otherwise it will return some other content. 
Then I create a rule to fire the tag each time the macro is equals to 404

I create the version of google tags and publish it.  Then by adding some random string on my url I can trigger a 404 error page.  But on the google analytics nothing is tracked.  Any idea what I am doing wrong?  Is this the right way of using custom macros?  Is there any problem on my macro or is something that I forget to do? 

A:

Add an additional condition to your rule, like {{event}} equals gtm.dom.