+1 vote
in ReactJS by

How to add Google Analytics for React Router?

1 Answer

0 votes
by

Add a listener on the history object to record each page view:

history.listen(function (location) {
  window.ga('set', 'page', location.pathname + location.search)
  window.ga('send', 'pageview', location.pathname + location.search)
})

Related questions

+1 vote
asked Mar 2, 2020 in ReactJS by RShastri
0 votes
0 votes
asked Mar 2, 2020 in ReactJS by RShastri
...