guillaumeparis2000 / react-piwik

Library that allow to connect piwik with the react-router and track custom events
31 stars 17 forks source link

Initial page view is not tracked #35

Closed totutotu closed 4 years ago

totutotu commented 4 years ago

When first entering a site the first page view is not being tracked.

This issue was fixed a long time ago in this commit but the fix has since been removed.

When initiating to use of react-piwik by using the "connectToHistory" function the previousPath local variable is set to current page the user is on here. Because the "previousPath" variable is in fact the same location that the user is currently on, the listening track() function does not recognize the first page as a trackable visit.

Edit: Update: Seems history.listen does not trigget the first trigger of the track function, so a solution would be to manually trigger the track function on "connectToHistory" with the initial location.

guillaumeparis2000 commented 4 years ago

Thanks for the fix, I publish it in version v1.10.0.