Skip to main content
InterviewHubPRO
Section Overview
Q69

Question 69 of 407

General

17%
React Core & Hooks (407 Qs)•General

How to add Google Analytics for React Router?

mid LevelCode ExampleRouting

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

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