DEV Community

dodou
dodou

Posted on

Localized Rank Tracking: hl + gl for 200+ Countries

Rank tracking gets complicated when your keyword is "coffee" and your customers are in Shanghai, London, and Tokyo. The same query ranks differently per country and language. That's what hl and gl are for.

SerpBase supports 200+ countries via hl (interface language) + gl (country), plus lat/lng/zoom for Maps. This post shows a rank tracker that monitors one keyword across several locales.

The code

import requests
from datetime import datetime

API = "https://api.serpbase.dev"
KEY = "your_api_key"

LOCALES = [
    ("zh-CN", "cn"),
    ("en", "us"),
    ("ja", "jp"),
    ("ko", "kr"),
    ("de", "de"),
    ("fr", "fr"),
]

def track(query, locales=LOCALES):
    rows = []
    for hl, gl in locales:
        r = requests.post(
            f"{API}/google/search",
            headers={"X-API-Key": KEY},
            json={"q": query, "hl": hl, "gl": gl},
            timeout=10,
        )
        r.raise_for_status()
        data = r.json()
        organic = data.get("organic", [])
        rows.append({
            "query": query,
            "hl": hl,
            "gl": gl,
            "rank": organic[0].get("rank") if organic else None,
            "top_link": organic[0].get("link") if organic else None,
            "request_id": data.get("request_id"),
        })
    return rows

print(track("coffee beans"))
Enter fullscreen mode Exit fullscreen mode

What you get per locale

For each hl/gl, the response includes organic with rank per result. Tracking the same keyword across locales shows which markets you rank for and which you don't.

Cost

6 locales × 100 keywords × 1x/day = 600 searches/day. At the Growth rate ($0.40/1k), that's about $7/month. Multi-market monitoring is cheap because each locale is one 1-credit search.

Honest caveats

  • rank varies by location AND language. Track the same hl/gl pair consistently, or numbers aren't comparable.
  • Localized results change more than a single-locale view; daily polling is usually enough.
  • For local (Maps) ranking, use the Maps endpoints with lat/lng/zoom — search alone covers organic only.

Full parameter and response reference: serpbase.dev/docs.

Top comments (0)