DEV Community

Cover image for Tracking Keyword Rankings Across Countries and Devices: What I Learned
Burhan
Burhan

Posted on

Tracking Keyword Rankings Across Countries and Devices: What I Learned

I needed to check how my keywords rank across different countries and devices, so I built a script using the SERPSpur Live Search Engine Ranking Checker API. It's surprisingly straightforward:

python
import requests

API_KEY = "your_api_key_here"

def check_rankings(keyword, location, device):
response = requests.get(
"https://api.serpspur.com/v1/rankings",
headers={"Authorization": f"Bearer {API_KEY}"},
params={"q": keyword, "location": location, "device": device, "lang": "en"}
)
data = response.json()
return data['rankings']

keyword = "SEO tools"
rankings = check_rankings(keyword, "United States", "mobile")
print(f"Keyword: {keyword}")
for rank in rankings:
print(f" Position: {rank['position']} | URL: {rank['url']}")

This helped me spot that my site ranks better on desktop than mobile for some terms. Have you noticed similar device-based ranking differences in your own work?

Top comments (3)

Collapse
 
zaylee90 profile image
Zaylee

Nice work! I've found that running the same script across multiple countries reveals how localized SERPs can be. For example, 'SEO tools' in the UK vs US often shows entirely different top results. Do you automate this for batch keywords too?

Collapse
 
micheljee profile image
Michel Jee

Interesting approach! I've definitely noticed mobile vs desktop ranking gaps too—especially for local keywords where mobile tends to favor nearby results more heavily. Have you tried comparing different locations as well? That's where I've seen the biggest surprises.

Collapse
 
emma-watson3 profile image
Emma Watson

That's a neat implementation. I've definitely seen device-based ranking differences, especially with local-intent keywords where mobile often outranks desktop. It's wild how much the SERP layout changes between devices—curious if you've noticed any patterns with featured snippets showing up differently too?