Google Custom Search API & WordPress Popular Search Terms
So you’ve integrated the Google Custom Search API into your site and now you want to show your users some of the most commonly searched terms on the site. There are a few WordPress plugins out there, such as Search Meter, that do a fantastic job of allowing you to display Recent Search Terms and/or Most Popular Search Terms on your site. But how do you display a list of popular search terms when the user is searching via the Google Custom Search API?
This Land Press came to us with a feature request to display the Most Frequently Searched terms made on their site from a specific date range. We had previously set them up with the Google Custom Search API…so now we just needed to pull in the search data via the Google Analytics API and provide them with a way to manage all of the data through the WordPress admin area.
WordPress needs to be linked to your Google Analytics account but once that’s complete, we were able to pull in the most frequently searched terms for a specific date range. The user can then select the terms that they’d like to appear on the site (or they can select terms to exclude). There’s a ton of functionality that can be built onto this to display additional data or to filter out terms, but this was a good starting point.
Note: In order to track search queries made on your site through Google Analytics, you’ll need to configure Google Analytics Site Search. Read more about it here.