diff --git a/components/MetaData.tsx b/components/MetaData.tsx index 5abfffd68..030540ad5 100644 --- a/components/MetaData.tsx +++ b/components/MetaData.tsx @@ -47,14 +47,19 @@ const MetaData = ({ language, data }: MetaDataProps) => { const handleRouteChange = () => { // only push event if pathname is different if (window.location.pathname !== appPreviousLocationPathname) { - window.adobeDataLayer?.push?.({ event: 'pageLoad' }) + if (isErrorPage) { + window.adobeDataLayer?.push?.({ + event: 'error', + error: { + name: d.statusCode, + }, + }) + } else { + window.adobeDataLayer?.push?.({ event: 'pageLoad' }) + } appPreviousLocationPathname = window.location.pathname } } - if (isErrorPage) { - // Suppress the pageLoad entirely on error pages - return - } handleRouteChange() router.events.on('routeChangeComplete', handleRouteChange)