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

Change matomo site search tracking to use trackSiteSearch #1772

Merged
merged 6 commits into from
Mar 18, 2024

Conversation

Sandravaphilips
Copy link
Collaborator

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

@@ -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);
Copy link
Contributor

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 the search_* fields; eg search__title=x&search__content=-y
  • category: use the document type and court facets, if in use, separated by semicolons; eg. Judgment; High Court or High Court or Judgment

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)

@Sandravaphilips
Copy link
Collaborator Author

Sandravaphilips commented Mar 14, 2024

@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.
To separate multiple values of a facet, I used a semicolon. For different facets, I used a comma as mentioned here
Also, GA allows the same arguments as matomo, so I did the same thing there.

@longhotsummer
Copy link
Contributor

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.

longhotsummer
longhotsummer previously approved these changes Mar 18, 2024
Copy link
Contributor

@longhotsummer longhotsummer left a 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 = '';
Copy link
Contributor

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.

@Sandravaphilips Sandravaphilips merged commit a1c56e1 into main Mar 18, 2024
9 checks passed
@Sandravaphilips Sandravaphilips deleted the sandrava-1757 branch March 18, 2024 12:53
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.

Change matomo site search tracking to use trackSiteSearch
2 participants