-
-
Notifications
You must be signed in to change notification settings - Fork 11
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 search analytics for Matomo #16
Comments
I found this comment that talks about an approach to hook into autocomplete.js with a plugin. It talks about sending the events to Algolia, but may be you could build a custom plugin to send the data to Matamo. |
Thanks for the hint @jasonbosco . I spent some time today to build the Can you point to a resource that helps me with onboarding to build locally, where to find the built artifacts and where to start hacking? Thanks. |
The build should be just running:
The build artifacts will then be inside |
Thanks. For
Which file best fits to |
You'd want to use the |
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
Thanks for your tips. I hacked around a bit these days and came up with #17. In my local setup it works so far and I receive the site search keywords in Matomo. I'm not very familiar with React and TypeScript. Can you please have a look at the lines and give feedback? That would be great, thanks. |
@ngulden Your approach seems reasonable and minimally invasive IMO, so looks good to me! Although, I'd prefer to not merge the code into this repo because it's very Matamo specific. But I think your PR can still be a great reference point for others to implement their own FE-based analytics tracking, so thank you for documenting your approach in the PR. |
The PR is a prototype as starting point. I'd like to have it more configurable. I envision to activate it through a parameter to the docsearch() function that I or other users just add when integrating typesense-docsearch.js to their <script> section in their HTML file. Do you have a hint how I could accomplish it? |
I added a parameter to configure the Matomo plugin. Per default, it's deactivated. Maybe, this implementation fits better. |
Since this hooks into autocomplete-js, I think it might be better to publish the matamo specific pieces as a separate autocomplete-js plugin, and then in DocSearch, only add the ability to use any autocomplete-js plugin. |
I'm not familiar with the ecosystem and publishing my contribution as separate piece of work. Furthermore, I don't have the capacity for maintenance. Thanks for your assistance @jasonbosco . To me, the piece of code works and I use it productively for some days now. It's available as a pull request for others interested in the same topic. |
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
Describe the problem
I use typesense-docsearch.js as search interface to a product documentation site at https://docs.software-univention.de.
I like the interface and how quickly I could get it productive.
I use Matomo for website analytics. To further improve our documentation, I'd also like to use search analytics together with Matomo.
Describe the solution
I need a way to capture the search term in the UI and send it for search analytics to Matomo. For using website tracking with Matomo, see https://developer.matomo.org/guides/tracking-javascript-guide#internal-search-tracking
I just want to configure it as parameter for docsearch in JavaScript.
Alternatives you've considered
One alternative would be building my own search UI with InstantSearch.js. To me this looks like an overkill, because I would need to duplicate the logic and the design within typesense-docsearch.js.
Which solutions do you have in mind?
The text was updated successfully, but these errors were encountered: