DIY Unit Testing for SEO

This is part of a series focusing on solving problems specifically for those working on large websites/large groups of websites.

As much as we'd love it, not every problem can be solved can be solved by buying Piped Out and getting a data warehouse... But they are common problems our customers bump into so we're sharing common solutions.

What's the problem

It's hard to keep track of everything going on on big websites/lots of websites.

Change detection is ok, but ideally we want to know if the value is correct, not if it's changed. The later doesn't tell us how to fix it.

How can we make this easier?

Criteria:

  • We can if check common SEO values (e.g. title, meta, canonical tag) have the correct value for a set of URLs.
  • We get a true or false response.
  • It's quick (<5 minutes).

Which is pretty much a unit test....

Ok this isn't technically a unit test. It's more like an integration test. And well it's still not technically one of those because it doesn't run in a CI process...

But on the plus side a developer doesn't have to make it so... ¯\_(ツ)_/¯

What's our answer?

The quick and dirty version is a Google sheet.

example_sheet

How does it work?

1. Make a copy

You're going to need to make a copy of the following Google sheet.

We've prefilled it with some AutoTrader URLs so you can see how it would be used.

2. Add in any URLs

Go to the correct values tab and add in any URLs you want. Typically I would add one (maybe two URLs) for each template. Remember we want this to be fast!

You fill in the first two columns:

  • Type: This is the type of page - category, product etc.
  • URL: This is the URL that will be checked.

Those URLs should then be pulled through to the other tabs.

3. Add the correct values

For each URL specify the correct values in each column.

4. Run it

Hit change detection and run Check URLs

example_sheet

The current values will be updated in the Current values sheet.

5. Check if everything is ok

Head to the Are the tests passed sheet and look for any values which are false.

example_sheet

In the example I've deliberately set the title to have different value to live, so we can see a 'bug'.

If they are false, check the Changes from correct sheet to see what has changed.

6. Rinse and repeat

When you repeat you'll want to hit the menu option Save current to previous first. It will save the current values to previous, so you can also check the previous value as well as if the current one is correct.

Extending it

You'll notice it doesn't check everything. Typically I'd end up customizing this If I was doing consulting for the client.

For those comfortable with JS, it's relatively basic. You need to:

  1. Pick something you want to check.
  2. Write a function to check it.
  3. Return a value as a property of the object returned by getUsefulSEOMetrics
  4. The name of the property should be the ID of the column. (Which is in row B and hidden by default.)

The sheet has a bunch of helper functions to make that easier and uses Cheerio for HTML parsing, because integration was easy.

That's all folks

Hopefully you'll find this useful.

If you've got questions tweet away and if you do have data challenges please feel free to reach out about Piped Out!

Dom Woodman Headshot
By Dominic Woodman -- I'm the founder of Piped Out and have never loved 3rd person bio's.

If you'd like a demo/quote, please contact us!

Book a demo