joernroeder / piwik-react-router

Piwik analytics component for react-router
https://www.npmjs.org/package/piwik-react-router
MIT License
61 stars 22 forks source link

react-router-dom #59

Open ujjalacharya opened 4 years ago

ujjalacharya commented 4 years ago

does it support react-router-dom@5+

jonfreedman commented 4 years ago

Yes, I have this working

borysfranc commented 4 years ago

@jonfreedman Hey, could you give any example how to get this work with BrowserRouter?

jonfreedman commented 4 years ago

See https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/Router.md#router

You need to replace BrowserRouter with Router and call createBrowserHistory() e.g

const history = createBrowserHistory();
const matomo = PiwikReactRouter({
    clientTrackerName: 'matomo.js',
    serverTrackerName: 'matomo.php',
    siteId: matomoSiteId,
    url: matomoUrl
});
return (
    <Router history={matomo.connectToHistory(history)}>
        <YourApp />
    </Router>
);
borysfranc commented 4 years ago

@jonfreedman Thanks a lot for your answer ! I managed to get the same solution, but thanks again for your response :)