404 page tracking

According to this:


to enable to differentiate a 404 pageview/visit I would need to place the tracking code with a specific snippet onto our 404 page. So copy the javascript code before the last .

We use WordPress & the only place with is the footer.php which already has the normal Piwik tracking code in place.

  1. How do I add this to my 404.php which has not
  2. How do I stop Piwik from tracking the page twice - once from the footer.php for the site & once from the 404.php?


in Wordpress create a custom 404 template, then add the tracking code to this custom template.

Or use the WP function is_404() to find out if current page is 404