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?
- 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.
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
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.
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.
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:
- Pick something you want to check.
- Write a function to check it.
- Return a value as a property of the object returned by
- 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!