A friendly guide on how to render HTML or site screenshots in Google Sheets in less than 10 minutes

It is not the first time that one of the ScreenshotOne users asked how to render screenshots in Google Sheets. I wrote a simple but complete tutorial once and for all.

Blog post4 min read

Written by

Dmytro Krasun

Updated on

You can do it in 3 simple steps:

  1. Sign up to ScreenshotOne and get an access key to a website screenshot API.
  2. Prepare a screenshot URL template.
  3. Render site screenshots in Google Sheets.

That will be our final result:

The final result

You can copy and modify the sheet for your needs.

Let’s quickly go through each step and its nuances in achieving the result.

Get an access key to the website screenshot API

To render screenshots, you need to get an access key to the ScreenshotOne API.

The API is free to start with 100 monthly screenshots to ensure you are satisfied with the quality before subscribing and paying.

You also might consider using other screenshot APIs. It is up to you. Most of the APIs have more or less the same format so that you can apply the tutorial for them too.

Once you have an access key, we can move to the next step and prepare a website screenshot URL template that we will use to fetch images.

Prepare a screenshot URL template

Before rendering screenshots, we need to set up an API URL template for requests. Without any advanced options, it might look like this:

https://api.screenshotone.com/take?access_key=<your access key>&url=

It is important the URL is the last one and is empty because we are going to set it for each cell. If you need more parameters, add them in between.

For most cases, especially listings in a website directory, I recommend starting with this template:

https://api.screenshotone.com/take?access_key=<your access key>&viewport_width=1280&viewport_height=800&format=jpg&block_ads=true&block_cookie_banners=true&block_banners_by_heuristics=true&cache=true&cache_ttl=2592000&url=

It gives you consistent screenshots of the same size, hides ads and cookie banners, and caches each screenshot for up to a month. Cached screenshots don’t count toward your quota. You can check all the options to tune it further.

Put the template in a separate cell or page—choose what works best for you.

The template

And let’s render screenshots.

Render website screenshots

If you plan to share or expose links of the screenshots, use signed links to prevent using your API key even if exposed. And require signing for every request (in the “dashboard” app).

For example I created 3 columns table with a readable name of the site, site URL, and screenshot:

A row

Let’s use the CONCAT and the IMAGE functions to render screenshots.

A formula

The CONCAT function concatenates strings, so by joining the URL template and the site URL, we will receive the actual URL of the screenshot, and by applying the IMAGE function, we can render it. You can copy the formula:

=IMAGE(CONCAT($B$1, ENCODEURL(B4)))

Don’t skip ENCODEURL. Site URLs often contain ? and &, like https://example.com/?ref=directory&lang=en, and without encoding, everything after the first & would be treated as a separate API option instead of a part of the site URL. The $B$1 reference keeps the template cell fixed when you drag the formula down.

Applying the formula to each row will result in what we wanted to achieve:

The final result

Google Sheets don’t render screenshots immediately. It might take some time until you see them.

You can copy and modify the sheet for your needs.

Screenshots for a website directory

If you build a directory, the same spreadsheet works as a screenshot pipeline for all your listings:

  1. Keep one row per listing with its URL.
  2. Generate the screenshot URL with the formula above, preferably as a signed link.
  3. Use the generated URL directly as the image source on your directory site, like <img src="...">, or import the column into your directory builder.

The screenshot URL is the image itself, so you don’t need to download screenshots or write any scripts. Only successful screenshots are charged, and cached ones are free. Keep in mind that the cache lives at most a month, after which the screenshot is rendered again on the next request. If you want to keep screenshots permanently, upload them to your own S3-compatible storage.

If you build your directory with Directify or Dirstarter, they already integrate with ScreenshotOne.

We need to make a few changes to use signed links instead of regular links. Let’s add the function allowing us to sign the query string for every request and return the signed screenshot URL.

Open the “Apps Script” editor:

Apps Script

Copy and paste the following function:

function SIGNED_REQUEST_URL(siteUrl, queryString, accessKey, secretKey) {
const forSigning =`url=${encodeURIComponent(siteUrl)}&${queryString}&access_key=${accessKey}`;
const hash = Utilities.computeHmacSha256Signature(forSigning, secretKey);
let signature = '';
for (j = 0; j <hash.length; j++) {
let byte = hash[j];
if (byte < 0) {
byte += 256;
}
if (byte.toString(16).length == 1) {
signature += "0";
}
signature += byte.toString(16);
}
return `https://api.screenshotone.com/take?${forSigning}&signature=${signature}`;
}

The function encodes the site URL itself, so pass the raw site URL to it without ENCODEURL. And put your options into queryString without the access_key and url parameters, for example, viewport_width=1280&viewport_height=800&block_ads=true&block_cookie_banners=true&cache=true&cache_ttl=2592000.

Then save it:

The function

Once the function is saved, let’s edit the formula:

The formula

And now we have rendered “signed” screenshots:

Signed screenshots

Feel free to reach the support

That’s it. That’s how simple it was. If you have any questions and decide to go with ScreenshotOne, feel free to ask any questions related to the topic at support@screenshotone.com.

Read more posts

Interviews, tips, guides, industry best practices, and news.

View all posts
Monitoring website changes

Monitoring website changes

I tried many ways to monitor and detect website changes. But I was always disappointed by the results. I want to share a few tips that might help you to get better results, if you plan to do the same.

Read more

Automate website screenshots

Exhaustive documentation, ready SDKs, no-code tools, and other automation to help you render website screenshots and outsource all the boring work related to that to us.