Skip to content

Track 404 tracking

Track

404 tracking

Find the broken links that send visitors to pages that do not exist, and see which page each broken link sits on.

This page shows how to list the missing pages your visitors run into. After reading it you can mark your "page not found" template, find the list in the dashboard, and track a broken link back to the page it sits on.

Why missing pages are worth seeing #

A visitor who lands on "page not found" often leaves. The cause is usually small: a link with a typing mistake, a page that was renamed, an old address that is still shared somewhere. You cannot fix what you do not know about, and nobody writes to tell you. A list of the missing addresses, with the page that linked to each, turns this into a short job.

Mark your not-found page #

A script in the browser cannot see the status a server answered with, so it cannot tell by itself that a page is missing. You tell it, by putting one attribute on the template your site shows for a missing page:

<main data-clearsaga-not-found>...</main>

The attribute is data-clearsaga-not-found. It needs no value and can sit on any element, as long as that element is present on the not-found page and on no other page. A hidden element counts too. A wrapper around the content of the template is a good place. Do not put it in a layout that every page shares, or every page would be reported as missing.

Both scripts support this, the light one and the full one. There is no setting to switch on in the dashboard: the attribute is all it takes.

Because the script looks for the attribute and not for a status, a page that shows "not found" while the server answered normally is listed too, as long as the mark is in the page when the script looks. Apps that draw their pages in the browser need care here, as the section on single-page apps below explains.

What is recorded #

When a marked page is opened, two hits are sent:

  1. The normal page view, as for any page.
  2. A hit of the type 404 with the path of the missing page and, when it is known, the page that linked there.

Each of the two is stored and uses one unit of your monthly allowance, so a missing page costs two. The same path is reported once per page load at most, however often the visitor returns to it without reloading.

The 404 hit carries no campaign tags, and the query string of an address is left out, as it is everywhere.

Single-page apps #

When the script looks for the mark depends on how the page was reached.

The first load of a page. The script looks once, as soon as the page has been read and the first page view has gone out. It does not wait and it does not look a second time. An app that draws its not-found view in the browser after that moment, for example once a request for data has answered, is not listed for that load. This is the case that matters most, because a visitor who follows a broken link from another site arrives exactly this way. Put the marked element in the page your server sends, or in the first thing your app draws, before any request for data.

A change of page without a reload. The script looks again after every such change. It waits 300 milliseconds first, to give your app time to draw the new view. If the not-found view appears later than that, for example after a slow request to your server, the mark is missed for that view too. Render the marked element as early as you can.

Where the missing pages are listed #

Open the Overview of a site and find the Pages card. Its last tab is "404s".

Each row is one missing path, the most hit first, with:

  • Hits. How often the path was opened in the date range.
  • A line starting with "from". The page that most often linked to this path.

The button in the corner of the card opens the full list. It adds a Sources column, which counts how many different pages linked to the path.

Missing pages also appear in the activity log of the Events screen, on the All tab, each as a row of its own. They are kept apart from your custom events, so they never show up in an event list, a conversion goal or a funnel. 404 is a name the script keeps for itself: a custom event cannot use it.

The hostname filter and the filters about a visit, such as country, device and source, narrow the list. The page, event, property and conversion filters do not apply to it, and a note under the card says so when one of them is set.

Until the first missing page has been recorded, the tab explains how to add the attribute.

What the linking page tells you #

The "from" line is where the fix is.

  • A path of your own site, such as /blog/launch. A link on that page is broken. Open it and correct the link.
  • Another site, shown with its address and path. Someone else links to an address that does not exist on your site. You can ask them to fix it, or set up a redirect from the old address on your side.
  • "Direct or unknown". No linking page was seen. The visitor typed the address, used a bookmark, or came from a place that hides where visitors come from. A redirect is the usual answer.

For a page view, only the site a visitor came from is recorded, never the exact page. The 404 hit is the one exception: it keeps the path of the linking page, because without it the list would not help. The query string of that page is still removed. Privacy: cookieless by default describes what is and is not collected.

Next: The dashboard, Custom events, Add the tracker