title: Unable to connect ReactJS App with google analytics
body: <p>I am trying to connect my personal website made using ReactJS to Google Analytics. I have followed <a href="https://www.youtube.com/watch?v=H-D-kaCjKfc" rel="nofollow noreferrer">this</a> tutorial but I am still not able to see an active user (when I access the site on local host or when I deploy it using netlify).</p>
  <p>Here is my app.js:</p>
  <pre><code>import React, {useEffect} from 'react';
  import Courses from './containers/Courses/Courses';
  import Home from './containers/Home/Home';
  import {Route, Switch, Redirect} from 'react-router-dom';
  import Layout from './hoc/Layout/Layout';
  import About from './containers/About/About';
  import ContactPage from './containers/ContactPage/ContactPage';
  import Projects from './components/Projects/Projects';
  import ReactGa from 'react-ga';
  
  
  const App = () =&gt; {
    
    useEffect(() =&gt; {
      document.title = &quot;Dhruv Mittal&quot;;
      ReactGa.initialize('UA-XXXXXXXXX-X');
      //Report page view 
      ReactGa.pageview(window.location.pathname + window.location.search);
    }, []);
  
    let routes = (
      &lt;Switch&gt;
        &lt;Route path=&quot;/about&quot; component={About}/&gt;
        &lt;Route path=&quot;/projects&quot; component={Projects}/&gt;
        &lt;Route path=&quot;/courses&quot; component={Courses}/&gt;
        &lt;Route path=&quot;/contact&quot; exact component={ContactPage}/&gt;
        &lt;Route path=&quot;/&quot; component={Home}/&gt;
        &lt;Redirect to='/'/&gt;
      &lt;/Switch&gt;
    );
  
    return (
      &lt;div&gt;
        &lt;Layout&gt;
          {routes}
        &lt;/Layout&gt;
      &lt;/div&gt;
    );
  
  }
  
  export default App;
  
  </code></pre>