How to set up Google Analytics for React-Router?

Posted by Rohit Kumar | Updated on

Want to set up Google Analytics for React-Router? This post will show you how to use Google Analytics with React Router V4 in three easy steps. While you can’t just paste in your embed code and be done with it, it’s still pretty easy to use Google Analytics in a single page application.

Then add a listener to record each pageview. (This assumes you’ve already set up the window.ga object in the usual manner.)


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers