EmmanuelRoux / ngx-matomo-client

Matomo analytics client for Angular applications
https://matomo.org/
MIT License
74 stars 16 forks source link

Site search track custom data #96

Open p-aron opened 1 month ago

p-aron commented 1 month ago

In matomo you can pass customData to siteSearch: https://github.com/matomo-org/matomo/blob/4061709f5ff7f11b9c74bb09168865a0950d387d/js/piwik.js#L7015

In the library MatomoTracker accepts 3 parameter: trackSiteSearch(keyword: string, category?: string, resultsCount?: number): void { this.delegate.push(['trackSiteSearch', keyword, category, resultsCount]); }

I have different filter options for querying some data. I would like to pass the filter options as custom data.

My question is that would it make sense to add customData to the trackSiteSearch method? Or setting the custom variables on the matomoTracker (this.matomoTracker.setCustomVariable) would do the same thing?

EmmanuelRoux commented 1 month ago

Hi @p-aron

You're right, that's an undocumented feature (see docs here).

But as the api actually exists, it could be added to trackSiteSearch, along with other similar methods. We could also add setCustomData method. (PR welcomed! 🙂)

Note: I think that custom data is just an alias to a custom variable named "data". So maybe setCustomVariable could suit your needs.