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 WPSnipp.com. 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
$h=(int)$h;
$w=(int)$w;
$q=esc_attr($q);
$geo=esc_attr($geo);
ob_start();
?>

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.