Steve Grunwell

Open-source contributor, speaker, and electronics tinkerer

Track WordPress Site Searches with McAvoy

Another week, another new plugin, it seems. This time, I’m proud to announce that McAvoy is now available in the repository!

McAvoy iconMcAvoy was born out of a client need to get information about what visitors are searching for on their site. While there are enterprise-level packages to do this and it’s pretty easy to set up in something like Google Analytics, our client wanted a solution that would simply collect information about what people were searching for and make it visible within the WordPress Admin dashboard. Pretty easy, right?

I had intended to fly somewhat under the radar with this project (at least in its infancy), but David Bisset (who follows me on GitHub and regularly tweets links to cool and interesting projects) picked up on within 24 hours of me writing the first line of code:

How does McAvoy work?

Whenever a search results page is loaded, the mcavoy_save_search_query action is called and passed two arguments: the search term and a filterable array of meta data. This information is then captured by one or more Loggers (version 0.1.0 contains a single DatabaseLogger, which saves search queries to a custom database table).

The base Logger class exposes a common API, enabling the rest of McAvoy (or anything that extends it) to easily swap out one Logger for another, leaving the implementation-specific logic to the individual Logger objects. For example, if someone wrote a Logger that worked with a service like Firebase, McAvoy could interact with it the same way it does the default DatabaseLogger.

Over time, the plan is to introduce a small library of different Logger implementations, so please feel free to add your suggestions and/or feedback to GitHub.

Who is “McAvoy”

This plugin was designed to answer five questions about your site’s audience, specifically those searching on it: “who”, “what”, “when”, “where”, and “why.” Those even somewhat familiar with journalism probably recognize the importance of those five questions, and as such I found it fitting to name the plugin after a journalist. Edward R Murrow, Walter Cronkite, and Dan Rather were all contenders, but ultimately ACN Anchor Will McAvoy won out.

Will McAvoy (Jeff Daniels) proclaiming that he will "single-handedly fix the internet!"


Of course, McAvoy is also available on GitHub, where feedback, bug reports, and pull requests are welcome. Hopefully McAvoy is helpful to you, and I’m excited to see where the plugin goes as it matures.


Enhance your Editorial Experience with Advanced Post Excerpt


Why Can’t I Change My Daughter’s Diaper?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Be excellent to each other.