braekling / WP-Matomo

Official WP-Matomo (former WP-Piwik) repository
GNU General Public License v3.0
31 stars 29 forks source link

Should search call both trackPageView and trackSiteSearch? #120

Open feedmeastraycat opened 8 months ago

feedmeastraycat commented 8 months ago

Copy of this question

We run a white label Matomo (self hosted) site and use this plugin to connect to it but Im wondering if search page tracking isn’t implemented wrong?

When visiting a search page I can see the following tracker code:

var _paq = window._paq = window._paq || [];
/* tracker methods like “setCustomDimension” should be called before “trackPageView” */
_paq.push(['trackSiteSearch','keyword', false, 1]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);

But according to the integration guide here: https://developer.matomo.org/guides/tracking-javascript-guide

Matomo says:

We recommend not to call trackPageView() on the Site Search Result page

Whenever a search is performed (when activating search tracking) two events are created. A call to tracker.php?search=$keyword and one to tracker.php?action_name=Search.

Is this a bug or a feature somehow? Won't this cause double search hits?