Automated Majestic Backlink Data in Google Sheets

Automated Majestic Backlink Data in Google Sheets

We use a variety tools to monitor backlink health, but I’ve always been drawn to the simplicity of Majestic SEO. Better still, Majestic’s API is fairly easy to incorporate into a Google Script – making automated data pulls a snap.

If you want to pull Majestic data directly into a Google Sheet, here’s how – but first, you need to have the appropriate API account. Details on that are available here.

Once you have your API code, create a new spreadsheet with a tab called “MajesticData”. Now open Google Scripts (Tools > Script Editor) and plunk down this bit of code:

Next, we need to tweak the URL variable in the second line of code. Replace “APIKEY” with your organization’s API key (obvious) and replace “DOMAIN” with the domain you want information on (doubly obvious). Once that’s done, run the script and grant any necessary permissions.

The script will return the raw JSON response, parse it and extract four data points: external backlinks, referring domains, Trust Flow and Citation Flow. This information is then appended to your “MajesticData” tab and sorted by newest first.

If you want the script to run at regular intervals, it’s easy to set up a trigger. While in the Script Editor, click “Resources” > “Current Project Triggers”, select the “majestic” function and set a time for the script to run. The nice thing about the appendRow method is that you’re never deleting any data – anytime the script runs, the new data just gets added to the existing information.

It’s worth noting that Majestic’s API can produce a host of different data points. This particular script calls the GetIndexItemInfo function, which includes other metrics such as last crawl date, referring IPs and subnets, redirects – most anything you can find in the web-based Majestic interface. There are quite a few other commands for retrieving different types of data – you can find a complete list on Majestic’s site.

What to do with all this data? That, my friends, is entirely up to you (within Majestic’s terms of service, of course). I use this script to check backlinks across our individual clients and ping the appropriate analysts when needed.

If you come up with a clever use for Majestic’s API, feel free to let us know!