title: How to use react-ga with HashRouter?
body: <p>I have been trying to integrate Google Analytics with my React App which uses HashRouter from react-router-dom v4. But it simply doesn't work complaining:</p>
  
  <blockquote>
    <p>Warning: &lt; HashRouter> ignores the history prop. To use a custom
    history, use <code>import { Router }</code> instead of <code>import { HashRouter as
    Router }</code>.</p>
  </blockquote>
  
  <p>The same question has been posted on Github here: <a href="https://github.com/gatsbyjs/gatsby/issues/1913" rel="nofollow noreferrer">HashRouter not responding to History</a> but no solutions provided yet. </p>
  
  <p><strong>I have to stick with HashRouter for the project without using any HOC.</strong> Is this possible?</p>
  
  <p>My current implementation:</p>
  
  <pre><code>ReactGA.initialize('UA-XXXXXXXX-X');
  const history = createHistory()
  history.listen((location, action) =&gt; {
    ReactGA.set({ page: location.pathname });
    ReactGA.pageview(location.pathname);
  });
  
  ReactDOM.render((
      &lt;HashRouter history={history}&gt;
          &lt;Switch&gt;
              &lt;Route path="/" name="App" component={App} /&gt;
          &lt;/Switch&gt;
      &lt;/HashRouter&gt;
  ),document.getElementById('root'));
  </code></pre>