Skip to content

Commit

Permalink
add support for changing /route/#hashes (#36079)
Browse files Browse the repository at this point in the history
update with-google-analytics example to also fire events when the hash section of the URL changes.
  • Loading branch information
williamli committed Apr 12, 2022
1 parent 7013a8c commit ad1b631
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/with-google-analytics/pages/_app.js
Expand Up @@ -10,8 +10,10 @@ const App = ({ Component, pageProps }) => {
gtag.pageview(url)
}
router.events.on('routeChangeComplete', handleRouteChange)
router.events.on('hashChangeComplete', handleRouteChange)
return () => {
router.events.off('routeChangeComplete', handleRouteChange)
router.events.off('hashChangeComplete', handleRouteChange)
}
}, [router.events])

Expand Down

0 comments on commit ad1b631

Please sign in to comment.