How To Track CDN Images in Search Console

A CDN (Content Delivery Network) is a great way to offload resources such as images, JavaScript and CSS from your server to another server that can deliver them more efficiently. For example, a CDN will host your resources across multiple servers in various locations so that when something is requested it can deliver it speedily from the server closest to the origin request. In addition to caching and compressing your resources, this gives your server much more bandwidth to load fewer resources, and as a result your page load speeds improve.

It’s quite commonplace for a CDN to use their domain in the URL for your resources, since they are the ones hosting them after all. Since custom CDN URLs matching your server are usually an added cost from CDN providers, most people settle for the server CDN URL, which usually looks something like this: 

https://your-site.example-cdn.com/

Since your images are being hosted on a different domain, they won’t show up in Google Search Console when you set up your site because you don’t have ownership of example-cdn.com. A step is required in order to authenticate your ability to access data.

Fortunately there is a way to have the best of both worlds! 

Read on to learn how to use a CDN for your resources and make sure all your images are being indexed, plus track all the valuable data for them in Google Search Console just as you would if you hosted the images yourself.

A Note on Google Analytics and Google Images

In case you are new to Google Analytics, it is worth noting that you won’t be able to drill down to referral traffic specifically from Google Images in Google Analytics. The Google Analytics team tested this and decided against it back in 2018:

After testing and further consideration, we have determined that the best place to measure query and click traffic from Google Images is in the Search Console Performance Report. Accordingly, we will continue to use https://www.google.com (or the appropriate ccTLD) as the referrer URL for all traffic from Google Images, and will not be providing a Google Images specific referrer URL (images.google.com)

https://developers.google.com/search/blog/2018/07/an-update-to-referral-source-urls-for

With that in mind, let’s get started with Google Search Console.

5 Steps to CDN Image Tracking in Google Search Console

1. Add a CNAME to your DNS Records

The first step involves adding a CNAME (Canonical Name) to your DNS (Domain Name Server) records. A CNAME can be used to alias one domain to another.

All hosting platforms have different interfaces but should all have a similar setup  for adding a CNAME entry. To achieve what we want for our images, we want to set up a subdomain. We’ll use the word ‘images’ for our subdomain, to make things easy to follow.

Here’s what it should look like:

TypeLabel/Host fieldTime To Live (TTL)Destination/Target field
CNAMEimagesLeave Defaulthttps://your-site.example-cdn.com/

This will allow Google to recognize an image hosted at:

https://your-site.example-cdn.com/image.jpg

is the same thing as

https://images.your-site.com/image.jpg

2. Add a Subdomain in Google Search Console

Next, we will want to add our newly created subdomain to Google Search Console.

  • Add a New Property in Google Search Console
  • Select the Domain property type and use the subdomain you created in your DNS records, excluding the protocol, e.g. images.your-site.com

Presumably your primary domain would already be set up in Google Search Console, and with that you should see this Ownership auto verified prompt:


Otherwise we recommend setting up your primary domain in Google Search Console too, and following the prompts to verify ownership.

3. Create an Image XML Sitemap

Once the subdomain is set up in Google Search Console, the next step is to create an XML Sitemap for all of the CDN image URLs. You can list up to 1,000 images in a single XML Sitemap, so if you have more than 1,000, simply create as many XML Sitemaps as you need.

To do this you could use a program like Screaming Frog to crawl your site and find all of the CDN image URLs populating under the External > Images section. From there you would simply filter the report to only show images on your CDN and not any other external sources. Here is a more comprehensive guide on how to complete the XML Sitemap generation with Screaming Frog once you have your list of images.

Alternatively, here’s a list of XML Sitemap generators that you can browse.

Name it something recognizable such as ‘images-sitemap.xml’ and upload it to the root of your primary domain so it can be found here:

https://www.your-site.com/images-sitemap.xml

Note that in order for your images to surface in Google Images, your images are required to be on an indexable landing page. Standalone images won’t get indexed. So don’t include any images in this XML Sitemap that do not have an associated landing page.

Consider Adding Image Metadata

Photographers, photo agencies, and other related industries are often required to provide information about their images in image metadata. They typically do this by embedding the image metadata in the image file with specific programs. This has the added benefit of displaying copyright information  in Image Search results (see right).

Image metadata isn’t just reserved for specific industries — anyone can add and use it, and it can be done via an XML Sitemap. The image metadata values that are available to use in an XML Sitemap include a caption, location, title and link to a license page.

This provides Google with more context around your images, which as a result can be better categorized in Image Search, which can in turn lead to higher quality traffic to your site. 

Below is an example of a single image entry in an XML Sitemap with metadata:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"><image:image>
<image:loc>https://toddowyoung.com/jason-aldean.jpg</image:loc><image:caption>Fireworks at a Jason Aldean Concert</image:caption><image:geo_location>New York, New York</image:geo_location><image:title>Jason Aldean Concert Fireworks</image:title><image:license>https://toddowyoung.com/image-license</image:license>
</image:image>
</url>
</urlset>

4. Add the Image XML Sitemap to robots.txt


Add a line in robots.txt that points to the new image XML Sitemap:

Sitemap: https://www.your-site.com/images-sitemap.xml


5. Submit the Image XML Sitemap to Google Search Console

Last step is to submit your images-sitemap.xml to the new subdomain profile that you set up in Google Search Console.

That’s it!

Now all you have to do is sit back and wait a couple of days for Google Search Console to begin associating your CDN images with your domain. 

Special Consideration for Yoast SEO and WordPress

If you are also using Yoast SEO plugin on WordPress, there is another step you can take to ensure images are being indexed properly.

Add the snippet of code below to the top of the functions.php file, replacing your-site in both URLs with your own, and images to your subdomain:

function wpseo_cdn_filter( $uri )
{
return str_replace('https://www.your-site.com', 'https://images.your-site.com', $uri );
}
add_filter( 'wpseo_xml_sitemap_img_src', 'wpseo_cdn_filter' );


This change will allow Yoast to properly generate the XML sitemap for your WordPress site by using the subdomain URL to reference your images.

Once you’ve updated the functions.php file, be sure to go into the Yoast SEO Sitemap settings and regenerate the XML sitemap.

What To Do With Image Data

Images are a fantastic way for your content to be discovered. An image can explain so much, so quickly. The key is to understand how you can leverage it for your site’s purpose. For example, for an online car parts business, a step-by-step guide for a Honda Civic engine rebuild can be far more useful with images than without. For a SaaS product, screenshots can help potential customers quickly see if your software is user-friendly or right for them.

As image data arrives in Google Search Console you will have a greater understanding of how users are finding your site through visual means.

Google Search Console will be able to show you the queries that people used, the pages these images were on, and subsequently may have visited. As well as the users’ device type and their countries. All valuable information that can help you see where your image strategy is most effective and where it may need more attention.

Take a step back on your content strategy and think through how you can integrate more unique, useful images to bring in more traffic through Google Image Search.

Related Posts

Leave a Reply

Your email address will not be published.