matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.4k stars 2.6k forks source link

PageViews with same PageViewId get counted as multiple PageViews #17833

Open JE4GLE opened 3 years ago

JE4GLE commented 3 years ago

I set the PageViewId in the JavaScript tracker using the new feature in this pull request: https://github.com/matomo-org/matomo/pull/17655 This is discussed in the follow issue: https://github.com/matomo-org/matomo/issues/16942

When I for example hardcode the PageViewId, I get multiple PageViews. Even if they have the same PageViewId!

Expected Behavior

When two or multiple tracked PageViews have the same PageViewId, they should only be counted as one visit.

Current Behavior

Every tracked PageView gets counted as an individual PageView, even having the same PageViewId.

Possible Solution

Count PageViews with the same PageViewID as one PageView.

Steps to Reproduce (for Bugs)

...
_paq.push(['setPageViewId', "563adi"]);
_paq.push(['trackPageView']);
...

Reload page multiple times.

Context

I'm trying to merge the PHP tracker and JavaScript tracker. Everything possible will be tracked by the PHP tracker, then the generated PageViewId will be passed on to the JavaScript tracker. This will track the rest, like browser features or screen resolution.

Your Environment

tsteur commented 3 years ago

@JE4GLE from our side this is currently expected behaviour. The same page view ID can be tracked multiple times currently. Defining the pageview ID was mostly meant for being also able to track performance client side while you track the page view server side.

In your tracking code you probably will want to remove "trackPageView" call and replace it by enableHeartBeatTimer. This should probably make it work for your use case to track the page view server side, and the "ping" request from the heart beat timer should eventually send the performance data.

JE4GLE commented 2 years ago

I will try removing trackPageView to track the performance, thank you! Does this also track plugin information?

tsteur commented 2 years ago

@JE4GLE I believe it doesn't track plugin information as this data is currently only tracked on the first tracking request within a visit which would be likely your server side "track pageview"