SEO: get the most of Images Search Engines. PHP script | Cardinal Path Blog
Blog

SEO: get the most of Images Search Engines. PHP script

Usually you won’t get a lot of traffic from Images Search – close to nothing in fact – but for certain web sites with a high volume of organic traffic, around 85%, and good quantity of search engine optimized images it can be close to 13% of the total visits.

This added traffic sure will help you get some extra conversions and who doesn’t want that?

Optimizing images is not that difficult, but it is a task you have to do every time you upload a picture. And unfortunately there is no easy way to know the yield of this work.

Web analytics tools are not going to tell you (at least not right out the box) the quantity of Image Search traffic, the keywords user searched at Google Images, the exact image that is appearing on the search engine results pages, nor the exact page in your site where the image is allocated.

PHP script to the rescue

It would be fantastic to have all these details to help your image optimization work and here is where I come in, with a piece of PHP code.

This script is doing three basic tasks:

  • Getting the referrer
  • Guess which of the major search engines is, Google, Yahoo or Bing
  • Analyze the query string and extract as many relevant details as possible

<?php

              // Get referral’s URL

              $referral_url = $_SERVER[“HTTP_REFERER”]

              // Parse referral

              $url = parse_url($referral_url);

              $url_decoded = urldecode($url[query]);

              $params = array();

              parse_str($url_decoded,$params);

              // Show details according to referral

              switch ($url[path]) {

                  case “/imgres”:

                            // Google Images

                            echo “<b>Search Engine:</b> $url[host]<br/>”;

                            echo “<b>Image url:</b> $params[imgurl]<br/>”;

                            echo “<b>Page of image:</b> $params[imgrefurl]<br/>”;

                            $prev_values = array();

                            parse_str($params[prev],$prev_values);

                            echo “<b>Keywords:</b> “.$prev_values[“/images?q”].”<br/>”;

                            break;

                  case “/images/view”:

                            // Yahoo Images

                            echo “<b>Search Engine:</b> $url[host]<br/>”;

                            echo “<b>Image url:</b> http://$params[imgurl]<br/>”;

                            echo “<b>Page of image:</b> $params[rurl]<br/>”;

                            echo “<b>Keywords:</b> $params[p]<br/>”;

                            break;

                  case “/images/search”:

                            // Bing Images

                            echo “<b>Search Engine:</b> $url[host]<br/>”;

                            echo “<b>Keywords:</b> $params[q]<br/>”;

                            break;

                  default:

                     echo “Non major Search Engine”;

              }

?>

What kind of data can be collected

Google Images is the one who is going to send most of this traffic, Yahoo Images send very little or nothing and the day I see Bing Images sending any visit is yet to come, but who knows?

Both Google and Yahoo are passing: keywords, Image URL and URL of the page in your site, as well as the search engine with the specific country code, so we can grab them all.

Bing is only going to tell the keywords the user searched, not surprisingly.

What else?

Feel free to modify the way you want the script to insert it in your site and collect all this data.

If your site is not using PHP as a server side script language you still can take the idea and replicate it in your favorite language.

My recommendation is to have a table in the database gathering the details with a time stamp, giving you some basic stats of when the visits from images are coming and the number of them.

More than just the insights you can get, this represents the possibility to delve into behavioral targeting according to what brought the visit to the site, just add your imagination.

 

Copyright © 2016, All Rights Reserved. Privacy and Copyright Policies.