I setup a data element that captures the "page not found" string from the title for our 404 page since it's the only indicator that the page is a 404 other than the image.
var pageNotFound = document.title;
Page load rule:
I then applied this to a page load rule (see below)
then added: s.pageType="errorPage" to the custom page code section
Question: is this a correct implementation in order for it to populate the page not found report or am i missing a step for correct implementation?
To confirm this is working as expected, visit a page that would throw a 404 error (yourdomain.com/asdf.html or something) and use your packet sniffer to check that pageType is getting set to errorPage:
Note that I have a filter applied to my Network tab in Chrome DevTools to b/ss so I'm evaluating only Adobe tags.
You can also use the Adobe debugger bookmarklet:
thank you for the information on how to check and confirm that the implementation is working. So, it looks like the pageType:"errorPage" is working correctly however, pageName is also getting set.
Question, I was looking in the global variables section in DTM because I was going to add an exclusion to remove pageName from any pages that had "Page not found" in the document.title however, the global variables settings do not have conditions. Is there another way to remove pageName from the pages that have "Page not found" in the document.title?
Any variable set in the global variables section will apply to every page. You'd need to either move the pageName in a page load rule with a condition, or you could create a rule in Analytics to change or drop that value when it's seen.
I would like to share our experience. We no longer populate Pages Not Found report. Two reasons for that:
1. All 404 pages will populate Page Name report nevertheless, and they will populate it with 404 page URLs, which is not very user friendly
2. Not all errors are page errors and not all page errors are 404. We found there is more value in capturing all sorts of errors in a dedicated report (including all 404 page errors), error URLs and user friends error page names in respective other reports
if you want to go ahead with populating the Pages Not Found report, then you will need to clear all global variables (that is including pageName and other global vars that you set in AA Tool) with clearVars function