Client Side Solutions
GTM Template
404-page-detector
This GTM (Google Tag Manager) custom template enables you to detect 404 error pages on your website and push an event to the dataLayer
when such pages are encountered. By using this template, you can track when users land on pages that do not exist (broken links, removed content, or mistyped URLs) and take appropriate actions to improve your site’s performance and user experience. Below is the datalayer event:
Features
- Automatic 404 Error Detection: Detects if a user lands on a 404 error page by using a fetch API.
- DataLayer Event Push: Pushes a custom event (
errorPage
) to the GTMdataLayer
when a 404 page is detected, allowing you to trigger other tags or send data to analytics tools. - Fully Customizable: You can modify the detection criteria or the event structure as needed.
Use Cases
- By detecting 404 error pages, you can quickly identify broken internal and external links that are leading users to non-existent pages.
- Use this information to prioritize fixing these links, improving your site’s SEO and user experience.
- Track user behavior when they land on a 404 page. Understand how users got there (referrals, mistyped URLs, old links) and how they behave afterward (e.g., do they leave the site or continue browsing?).
- This can help in reducing user drop-off and improving page navigation.
- Use the data to identify patterns of friction. If many users are encountering a 404 page from a certain referral or page, it may indicate a systemic problem with your site navigation or external sources linking to your site.
- You can then focus on enhancing your website’s UX to minimize such friction.
- For e-commerce and other goal-based sites, reduce the impact of broken links that lead to 404 errors and affect conversions. Identify critical conversion paths and ensure smooth navigation by addressing these errors.
- Set up automated alerts or workflows when 404 errors are detected. This can help your development or content management team quickly address and fix broken links before they cause further user frustration.