The annoying part of rank tracking is not searching for a keyword once. Anyone can do that.

The pain starts when someone asks why a result was fifth yesterday and missing today. Was the page actually pushed down? Did the query run in another country? Did the provider return fewer results? Did the scheduled job fail? Or did somebody quietly change the matching rule?

A spreadsheet full of positions cannot answer those questions. Worse, it can make a broken monitor look like an SEO trend.

That is why I prefer to treat rank checks like application telemetry. A search result is an observation produced under specific conditions. The position matters, but so do the conditions, response shape, and health of the check itself.

A rank is meaningless without context

People often talk about “the Google rank” as if a page has one permanent coordinate. A monitor asks a narrower question:

Where did this domain appear in the organic results returned for this query, locale, language, page, and collection time?

That wording prevents bad comparisons. A US English check and a UK English check are not two points on the same line. A first-page request and a multi-page request are not interchangeable either.

Store the query dimensions beside every observation rather than hiding them in configuration:

CREATE TABLE rank_observations ( observed_at TEXT NOT NULL, query TEXT NOT NULL, target_host TEXT NOT NULL, country TEXT NOT NULL, language TEXT NOT NULL, result_page INTEGER NOT NULL, requested_count INTEGER NOT NULL, returned_count INTEGER, outcome TEXT NOT NULL, position INTEGER, landing_url TEXT, error_class TEXT, response_digest TEXT ); 

SQLite is adequate for a small monitor. It ships with Python, is easy to back up, and keeps the first version boring. If the workflow later needs concurrent writers or a shared dashboard, the same event model can move to Postgres.

The important choice is not the database. It is refusing to save a position without the evidence that explains it.

“Not found” is not an error, and it is not rank 11

This is where small SEO scripts quietly corrupt their reports.

Suppose the API returns ten organic results and the target domain is absent. You know only that the domain was not present in the returned set. You do not know that it ranked eleventh.

Use at least three outcomes:

  • found: the response was valid and a matching result had a usable position
  • not_found: the response was valid but the target was absent
  • error: the request, decoding, or response validation failed

Keep position null for the last two. Do not insert 0, 999, or another magic number. Those values eventually leak into averages, and suddenly an outage looks like a ranking collapse.

Here is the core parser:

from urllib.parse import urlparse def normalize_host(value: str) -> str: candidate = value if "://" in value else f"https://{value}" hostname = urlparse(candidate).hostname if not hostname: raise ValueError("target is not a valid host") return hostname.lower().rstrip(".").encode("idna").decode("ascii") def belongs_to_target(url: str, target: str) -> bool: parsed = urlparse(url) if parsed.scheme not in {"http", "https"} or not parsed.hostname: return False host = normalize_host(parsed.hostname) return host == target or host.endswith("." + target) def extract_observation(payload: dict, target: str) -> dict: if not isinstance(payload, dict): raise ValueError("response must be an object") organic = payload.get("organic") if not isinstance(organic, list): raise ValueError("organic results are missing or invalid") matches = [] for item in organic: if not isinstance(item, dict): raise ValueError("organic result must be an object") position, link = item.get("position"), item.get("link") if type(position) is not int or position < 1: raise ValueError("invalid organic position") if not isinstance(link, str): raise ValueError("invalid organic link") if belongs_to_target(link, target): matches.append((position, link)) if not matches: return { "outcome": "not_found", "position": None, "landing_url": None, "returned_count": len(organic), } position, link = min(matches) return { "outcome": "found", "position": position, "landing_url": link, "returned_count": len(organic), } 

Hostname parsing matters. A substring check such as target in url can match an unrelated domain that merely contains the target name. That bug can survive for months because the output still looks plausible.

Whether subdomains count is a product decision. The code above treats shop.example.com as part of example.com. If the business cares only about the exact host, use equality. If it cares about one landing page, normalize and compare paths too. Changing the rule later creates a new metric, so write it down before collecting data.

Keep enough evidence to debug the monitor

Saving every raw response forever may be wasteful. Saving nothing is also a mistake.

A practical compromise is to keep the structured fields used by reports, a digest of the response, and raw payloads for a short retention window in protected storage.

import hashlib import json def response_digest(payload: dict) -> str: canonical = json.dumps( payload, ensure_ascii=False, sort_keys=True, separators=(",", ":"), ).encode("utf-8") return hashlib.sha256(canonical).hexdigest() 

Do not log authorization headers or put API keys in the keyword file. Read credentials from the scheduler secret store or environment. Remember that a variable available in an interactive shell may not exist inside cron or a hosted runner.

Repeated runs should also be safe. Schedulers retry, operators click buttons twice, and timeouts create uncertainty. Give each run an ID or use a uniqueness constraint so duplicate rows do not become fake volatility.

Alert on data quality before position changes

A monitor that sends “keyword dropped!” whenever position becomes null will train everyone to ignore it.

Calculate monitor health before ranking movement. Useful signals include the percentage of successful checks, the share of not_found outcomes, the median returned-result count, and response validation failures. Compare positions only when both observations are found and their query dimensions match.

def movement(previous: dict, current: dict): dimensions = ("query", "target_host", "country", "language", "result_page") if any(previous[key] != current[key] for key in dimensions): return None if previous["outcome"] != "found" or current["outcome"] != "found": return None # Positive means the page moved closer to position one. return previous["position"] - current["position"] 

This produces fewer exciting notifications, which is exactly the point. A trustworthy monitor should be conservative about what it claims.

If a keyword moved from eighth to fifth under matching conditions, saying it improved by three observed positions is fair. Saying a title change caused the improvement is not. Causality needs more evidence: release history, analytics, a longer time series, and awareness of other changes.

Scheduling is part of the measurement

You can run a small monitor from cron, a container scheduler, or a GitHub Actions workflow. The platform matters less than consistency.

Run at a stable time, make the time zone explicit, prevent overlapping jobs, and return a non-zero exit code when checks fail. Add bounded retries with backoff only for failures that are actually retryable. An authentication error or invalid schema will not become healthy because the script hammers the endpoint six more times.

Hosted schedules can also start later than their nominal time during busy periods. Store the real observation timestamp, not merely the intended schedule time.

Before expanding to hundreds of keywords, run a small set for a week. Look for duplicate executions, missing credentials, unexpected result counts, locale mistakes, and domains that match the wrong pages. A plain table with honest states is more useful than a polished dashboard backed by ambiguous data.

The crawler was never the product

Maintaining search-page selectors, proxy behavior, markup changes, and anti-bot edge cases can consume more time than analyzing rankings. A SERP API can remove much of that retrieval work, but it does not define the metric for you.

Your real job is to make each observation explainable. Fix the query conditions. Validate the response. Separate absence from failure. Preserve enough evidence to investigate surprises. Compare only compatible events.

Once those habits are in place, the daily chart becomes almost boring. That is a good outcome. Boring monitoring is usually the monitoring people can trust.

Reference

https://platform.acedata.cloud/blog/serp-api-daily-seo-rank-monitor?inviter_id=484695ca-9aeb-43eb-93c9-cc4a9a94e363