Skip to content

Commit ad1b631

Browse files
authored
add support for changing /route/#hashes (#36079)
update with-google-analytics example to also fire events when the hash section of the URL changes.
1 parent 7013a8c commit ad1b631

File tree

1 file changed

+2
-0
lines changed
  • examples/with-google-analytics/pages

1 file changed

+2
-0
lines changed

examples/with-google-analytics/pages/_app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ const App = ({ Component, pageProps }) => {
1010
gtag.pageview(url)
1111
}
1212
router.events.on('routeChangeComplete', handleRouteChange)
13+
router.events.on('hashChangeComplete', handleRouteChange)
1314
return () => {
1415
router.events.off('routeChangeComplete', handleRouteChange)
16+
router.events.off('hashChangeComplete', handleRouteChange)
1517
}
1618
}, [router.events])
1719

0 commit comments

Comments
 (0)