Searches bring users and users generate sales. This is why Keyword Rankings reports have been done since SEO was born. Having a tool that monitors and allows you to see the general status of the most relevant keywords to your business is essential for any SEO.

There are many Keyword Rankings tools that allow you to track the positioning of the most relevant keywords for your business. Some of them are paid and others are free. If you are looking for an easy solution to get out of trouble, we developed a simple snippet that allows you to extract all the relevant ranking information for a keyword from a search result page.


var keyword = $(‘input[name$=”q”]’).value

var results = $$(‘div[class=”r”]’);

var date = new Date().toISOString().split(‘T’)[0];

var content = ”;

for (var i = 0; i < results.length; i++){

var rank = i+1;

var current_url = results[i].innerHTML.match(/<a href=”([^”]*)/)[1];

var current_title = results[i].innerHTML.match(/<h3.*?>(.*?)</)[1];

content += ‘<tr><td>’ + date + ‘</td><td>’ + rank + ‘</td><td>’ + keyword + ‘</td><td>’ + current_title + ‘</td><td class=”tdurl”>’ + current_url + ‘</td></tr>’;


with(output = ‘<html><head><link href=”;700&display=swap” rel=”stylesheet”><style>body{font-family: \’Open Sans\’, sans-serif;}table{white-space:nowrap;}td{padding:0 15px;}.tdurl{max-width: 400px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}</style></head><body><table width=”100%”><tr><td><h1>Google SERP Extractor</h1></td><td align=”right”><img src=”” width=”200px”></td></tr></table><table><tbody><tr><th>Fecha</th><th>Rank</th><th>Keyword</th><td><b>Title</b></td><td><b>URL</b></td></tr>’, output += content, output += “</tbody></table></body></html>”, document.write(output), document.close()

In order to run this snippet correctly, it is important to remember that we have to be inspecting the Google SERP we want to analyze. If we load the Google Chrome DevTools (read, “the inspector”) in another tab, the code will not work.

 As in previous posts, to configure this SEO snippet we have to open the Chrome DevTools and go to the Sources tab. Inside the Sources tab we then go to the Snippets tab. It is likely that you will not see the Snippets tab at once and you will have to click on the two arrows icon to see all the tabs.

Once we are in Sources > Snippets, we go to “+ New Snippet”.

We name the snippet, paste the code above this post and then press Ctrl + S or ⌘ + S on Mac, and that’s it!

To run the snippet you have to right click on the script name and click “Run”. When you do this, a new tab should open with the following columns…

The result should be something similar to this…

The columns listed in the keyword rankings report are:

  • Date: Shows the date on which the script was run.
  • Rank: Shows the position in which the result appears on Google
  • Keyword: Displays the keyword for which the positioning is being viewed
  • Title: Displays the title of the page that ranks for that position
  • URL: Shows the URL that ranks for that position

In the case of the screenshot, 100 rankings are shown because Google Search is configured to show 100 results at a time. If you need to see more than 100 results, this can be achieved by using the gInfinity extension for Google Chrome.

This data can be copied and pasted directly into a Google Sheet or Excel spreadsheet. Once the file is ready, you can start saving the ranking data to see daily evolutions of both your site and your competitor’s site. If you just need to see how your site is ranking, you can see the historical data of your keywords up to 18 months ago.

We hope this SEO Snippet will be useful for your daily optimization routines and that you will be able to carry out a data-driven SEO strategy every time.

Until next time and, as always, good rankings!

Posted by:Dario Manoukian

Exclusive SEO agency. We are the first SEO agency certified as Great Place to Work. In 2018 & 2020 we were chosen as the Best Online Marketing Agency for eCommerce by eCommerceDay and The Best SEO agency in LATAM by Clutch.