Add an analytics event for search results count #5109
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes
Fixes #4561 by @obulat
Description
This PR introduces a new analytics event,
GET_SEARCH_RESULTS
, that logs the number of results returned for each user search query for each media type (image and audio). By addingGET_SEARCH_RESULTS
, we gain insight into queries that yield few or no results, enabling us to better understand and address potential gaps in openverse search capabilities.As was advised in issue #4561 a
GET_SEARCH_RESULTS
event was placed near the existingSUBMIT_SEARCH
event. The very sending of the event was implemented in thefetchSingleMediaType
function before we return mediaCount, if page is 1 (so, it fires once per a search term, and does not fire when user clicks on Load more)Testing Instructions
Project setup and initialisation was done according to the General setup guide, but despite this, for some reason analytical events were not sent to the Plausible server (http://0.0.0.0:50288/localhost), as it was unreachable for none of them. Even though it was started, initialised and there were no visible errors in logs. So, this didn't give the ability to test and see the stats directly in the form of a chart etc on Plausible server.

Despite this operability can be tested using the developer tools in the browser. The following image shows that events are successfully sent as intended without any visible bugs.

Checklist
Update index.md
).main
) or a parent feature branch.ov just catalog/generate-docs
for catalogPRs) or the media properties generator (
ov just catalog/generate-docs media-props
for the catalog or
ov just api/generate-docs
for the API) where applicable.Developer Certificate of Origin
Developer Certificate of Origin