1. Ensure the Page Title for 404 pages is:

image101

  1. Add GTM code to these 404 page templates:

blog.clientdomain.com/page-that-does-not-exist

www.clientdomain.com/page-that-does-not-exist

 

[Optional] To get extra detail on 404 errors you can enable this script to the 404 templates:

<script>

window.dataLayer = window.dataLayer || [];

dataLayer.push({

“pageHttpResponseCode”: “<?php http_response_code(); ?>“// e.g 404

});

</script>

 

Then GTM event can be triggered based on the documents.title=*404* OR pageHttpResponseCode=404. For example:

image102

image103

 

              

              

 

0117 3361103