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.91k stars 2.65k forks source link

Evaluate if site search requests are tracked correctly #21843

Open sgiehl opened 9 months ago

sgiehl commented 9 months ago

Matomo allows to track site searches. This can currently be achieved in two different ways:

While writing some tests I came across some inconsistency around how site searches are tracked compared to other actions, that we should evaluate for the correctness.

Tracking of Exit page url / title

When a page view is tracked, we automatically update the visit table dimensions visit_exit_idaction_name and visit_exit_idaction_url, which contain the page url and title of this page view. Those dimensions are currently only set when a page view happens. Except for site searches. If a site search is tracked, the visit_exit_idaction_name is updated to the keyword of the site search, while visit_exit_idaction_url is set to null.

Example:

A visitor comes to a page /test with title Title and an according page view is tracked. They use the search bar on the page, which directly provides suggestions in a drop down. For this action a manual site search action gets triggered for the keyword. The user leaves without clicking any of the entries.

Current Behavior

This user would end up in the database with two actions (correct), but his exit action would be set to the search keyword with no url.

Need for clarification

Is it considered correct, that this user cannot be found when e.g. segmenting for the exit page url \test or the title Title. The page /test would also not appear in the exit page reports.

Automatic conversion of page views to site searches

When site search keywords are configured, Matomo automatically tries to detect site searches by looking for certain keyword parameters. If such a keyword is found Matomo will only track a site search, but no page view.

Example

A visitor comes e.g. from a search engine to a url like /search?kwd=keyword. This page has a certain title and the implemented tracking code sends out a page view tracking request for the URL and title.

Current Behavior

As the url provided for tracking the pageview contains a configured site search keyword param, it will end up in tracking a visitor, only having exact one site search action, but no page view at all.

Need for clarification

Is it considered correct, to only track a site search in this case? Personally I would have expected a page view and a site search action to be tracked. Otherwise the page url and title that were originally provided for the page view are actually lost and stored nowhere. If you e.g. have a search on /search and that page is only opened after providing a search keyword, the page itself might actually never occur in the page reports.


@Stan-vw @tsteur @mattab Would you mind having a look at this one in order to clarify if those behaviors are correct? To me it feels unexpected to handle site searches that way.

mattab commented 9 months ago

Thanks for raising the issue! Here are my proposed answers (happy to listen to other suggestions of course, as always)

1 Need for clarification Is it considered correct, that this user cannot be found when e.g. segmenting for the exit page url \test or the title Title. The page /test would also not appear in the exit page reports.

it's not correct, if i understand right. So you're suggesting to set visit_exit_idaction_url to the existing page view URL tracked (if any), which sounds good to me.

(I haven't considered possible side effects, so after making these changes, It would be important to list here for review any other side effects we may find in tests or code)

2 Need for clarification Is it considered correct, to only track a site search in this case? Personally I would have expected a page view and a site search action to be tracked. Otherwise the page url and title that were originally provided for the page view are actually lost and stored nowhere. If you e.g. have a search on /search and that page is only opened after providing a search keyword, the page itself might actually never occur in the page reports.

this one I would say is correct. The idea was that, there was not much value in having a "page view" tracked for the Internal Search Result, because instead, we want to track these things as "site searches" in the dedicated site searches report, so that the "pages" report is kept clean and doesn't have 50 different pageview with unique searches. To keep "Pages" for real pages while "site searches" would have the "Internal Search pages" but focused on the keywords themselves instead of the URL and page titles.

MatomoForumNotifications commented 7 months ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/page-de-recherche-non-comptabilise-dans-les-pages-vues/55862/19

heurteph-ei commented 7 months ago

Additional notes for point #2: Documentation says the same: « Please note; when enabling the Site Search feature in Matomo using URL Parameters, the Site Searches that are tracked with this method will not register as a pageview in Matomo. Clicked pages from the results of a Site Search should be tracked as a pageview. » (from https://matomo.org/faq/reports/enable-site-search-tracking-for-your-website/). In my point of view, this is not true, as reports will miss one page viewed... This should at least be configurable via a checkbox "Track the search within a page view (if not checked, the site search will generate only search action, but no page view)". See also previous post from Matomo forum.