Jump to content

Implementing search statistics in PW


heldercervantes
 Share

Recommended Posts

How would you implement statistics for a PW search system? I want to A) develop something that in the future allows me to understand the trends of what users are searching for in the site, and B) understand if good answers have been given.

This second one is might sound trickier, but maybe it's actually easier. I can add a "Not what you're looking for?" button that, while providing the user some path to follow (even if it's opening the search box again), could also save the search term in a log of unfulfilled searches.

Storing logs for searches is what's bugging me more. The volume might become too great, and I have no idea how to do it in a way that lets me later discover the most and least popular search terms.

Link to comment
Share on other sites

  • heldercervantes changed the title to Implementing search statistics in PW

You could also use Matomo analytics (open source), which keeps track of site search keywords and searches with no results, as well as the most common pages visited as a result of a site search.

I reckon it’s ok to log searches to a file in ProcessWire as well. I was previously logging searches with no results to the messages log with:

wire('log')->message("No results for $searchTerms");

Or to log all results to a separate search log with:

wire('log')->save('search', $searchTerms);

Because the log files are saved in a consistent space-separated format they'd be possible to parse with a script (maybe reporting the results through a ProcessWire page), or import into a spreadsheet program.

We use the paid Form Builder module to allow users to answer a 'was this page helpful' question at the bottom of any page, including search.

Another way of recording the success of the search could be to put the results through an intermediate PHP script that logs the search position of the chosen search result, before redirecting users on to the actual result. So you could see if the first match is mostly chosen, or something further down the list.

  • Like 3
Link to comment
Share on other sites

In addition to that you also could save every new search query as a page, add a PageHitCounter to it, so every time someone search the exact query the counter goes up.

If necessary you could place some additional logic in your search query handling to present not a search result but a content page. That's something I'm working on right now. With this I could even place ads on some queries or push a result or whatever.

2021-11-16_14-56.png.3692b18e6001c17027b87021e2682807.png

Link to comment
Share on other sites

Thank you all for your contributions. In the end I think I'm gonna go with a mix of Google Analytics (great find) and search logs for the unsuccessful searches. It looks to me that this combo would give the best results for what I'm making. It's not an actual search, but a POC that's based on search.

Fingers crossed. If this works, it will be a really cool case study.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...