Skip to content

Commit

Permalink
Merge pull request #743 from DTS-STN/aa-double
Browse files Browse the repository at this point in the history
push error event
  • Loading branch information
Charles-Pham authored Oct 23, 2024
2 parents c6c1b12 + 7ce24a5 commit 507a8db
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions components/MetaData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 507a8db

Please sign in to comment.