How To Display Google Trends Graphs in WordPress

How To Display Google Trends Graphs in WordPress

Google Trends is a very handy tool for finding out what people are searching for around the world. Enter any search term and you’re instantly presented with the data for how often it is searched for, relative to the total number of global searches. Generally, this service is most often used for comparing the volume of searches between two or more terms.

Charts displaying comparison data make excellent fuel for conversation. Since Google loves for you to embed their products everywhere, it’s actually quite easy for you to get this data and display it within WordPress posts and pages.

This code comes to your courtesy of Kevin Chard of It allows you to use a shortcode to display a graph within your content. You can add this code to your theme’s functions.php file or create a little plugin for it.

{code type=php}
function wps_trend($atts){
extract( shortcode_atts( array(
‘w’ => ‘500’, // width
‘h’ => ‘330’, // height
‘q’ => ”, // query
‘geo’ => ‘US’, // geolocation
), $atts ) );
//format input

In order to display the chart, you will need to place the following shortcode within your post. You can change the values for the width, height, query and geolocation. Add a + between multiple words that are part of a single query. Here’s one example:

[trends h=”520″ w=”640″ q=”+family+law,+estate+planning” geo=”US”]

The resulting graph would look something like this and includes a link to the full report on Google Trends.

Google Trends graphs can be great visual tools for business bloggers, marketing analysts, SEO specialists and anyone who frequently compares brands and search terms. Take a minute to add the function one time and then you can use the shortcode whenever you need it.