Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plugin for Matomo to track site search keywords #17

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ngulden
Copy link

@ngulden ngulden commented Oct 17, 2023

Change Summary

Use the plugins API for autocomplete, hook into the state change, retrieve the query term from the use, and send the query term together with the search results from the global context to Matomo.

https://developer.matomo.org/guides/tracking-javascript-guide#internal-search-tracking

Relates to #16

The implementation requires that the Matomo tracking code is already part of the web page that calls the docsearch modal. It just references it and adds the call for the Matomo site search.

To use the plugin, you need to add matomoSearchAnalytics: true to the properties for the docsearch() function.

PR Checklist

Use the plugins API for autocomplete, hook into the state change,
retrieve the query term from the use, and send the query term together
with the search results from the global context to Matomo.

* autocomplete plugins: https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/plugins/
* autocomplete state: https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/state/
* autocomplete access data with context: https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/context/

https://developer.matomo.org/guides/tracking-javascript-guide#internal-search-tracking

Relates to typesense#16
The Matomo plugin only sends data under the following conditions:

* The modal UI is opened
* The query string has length greater than 0
* The query term wasn't used before

Increase debounce limit to 500 ms.
To activate the Matomo plugin, add `matomoSearchAnalytics: true` to the
properties in the call to the docsearch function. Per default, the
plugin is deactivated.
Only send search terms when they have a least three characters of
length. Otherwise, search analytics is cluttered with strings of no
further use.

Refs typesense#4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant