InterviewHubPRO
Section Overview
Q69

Question 69 of 445

Part 1: Core React, JSX & Component Architecture (1 - 77)

16%
React & Modern Frontend (445 Qs)•Part 1: Core React, JSX & Component Architecture (1 - 77)

How to add Google Analytics for React Router?

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);
});