title: Matomo (Piwik) tracks wrong URL in React App
body: <p>I have a SPA build around React with <code>react-router</code> using browser history API to handle location changes. I also have Matomo (formerly Piwik) installed and configured. </p>
  
  <p>I have written a middleware that listens for router's <code>@@router/LOCATION_CHANGE</code> action and calls Matomo tracker's <code>.trackPageVisit()</code> every time when such action is being fired.</p>
  
  <p>Problem is, that Matomo somehow tracks only the first page's URL each time.</p>
  
  <p>So, if I enter using <code>http://localhost</code> and then move to <code>http://localhost/page</code>, Matomo will track <code>http://localhost</code> twice instead of latter being <code>page</code>. When entering <code>/page</code> and moving to <code>/login</code> I will see in report <code>/page</code> being tracked twice. This lead me to a conclusion, that somehow Matomo does not handle browser's history manipulations through <code>history.pushState</code> in my configuration. I'm lookin for ideas what can be the reason.</p>