-
Notifications
You must be signed in to change notification settings - Fork 0
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
Change matomo site search tracking to use trackSiteSearch #1772
Conversation
@@ -639,6 +640,9 @@ export default { | |||
if (response.ok) { | |||
this.error = null; | |||
this.searchInfo = await response.json(); | |||
if (searchParams) { | |||
analytics.trackSiteSearch(searchParams, this.searchInfo.count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matomo lets us push three things:
- the search term
- a search category (optional)
- number of hits
Providing the full searchParams string is too overwhelming. Instead, let's do this:
- search term: use
q
for simple searches, for advanced searches provide all thesearch_*
fields; egsearch__title=x&search__content=-y
- category: use the document type and court facets, if in use, separated by semicolons; eg.
Judgment; High Court
orHigh Court
orJudgment
Using params
before it is turned into a string should make this a bit easier.
For GA, just include whatever it supports (probably just the search term)
@longhotsummer I'm not sure I understand the category part of your comment. Do you mean that we should only track document types and court facets? Because my recent changes track all facets if selected. |
Ok, this is looking much better. Please sanity check that date facets get pulled into the reporting, otherwise I think it's good to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great!
@@ -662,11 +662,13 @@ export default { | |||
const facets = []; | |||
const fields = this.facets.map(facet => facet.name).concat(['date__range', 'date__gte', 'date__lte']); | |||
|
|||
let currentKey = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better way of doing this is iterating over the keys only, not the key/value pairs. Then you don't need to de-dup like this.
Since the URL params contain both keywords and facets, I figured the easiest way to track would be to use the entire params as the keyword like this:
this.paq.push(['trackSiteSearch', keyword, false, searchCount]);
If you'd rather I destructure it instead, please let me know.
Closes #1757