How to Alert on Ranking Drops with Webhooks
Automated ranking drop webhooks notify engineering and SEO teams immediately when high-value keywords lose page-one positions or AI Overview citations. Rather than polling search APIs repeatedly, your server receives signed HTTP POST payloads when scheduled scans finish or alert conditions fire. By verifying the TrackSERPs-Signature header using HMAC-SHA256 and enforcing timestamp freshness, developers ensure notifications are authentic, prevent replay attacks, and route critical ranking alerts to Slack or incident management systems.
Key facts
- Webhooks send an HTTP POST as soon as a ranking event occurs, so you do not need to poll the API.Source: spec.openapis.org
- TrackSERPs signs webhook payloads with HMAC-SHA256, transmitted in the TrackSERPs-Signature header with timestamp validation.Source: rfc-editor.org
- Webhook timestamps older than five minutes (300 seconds) are rejected to safeguard against replay attacks.Source: rfc-editor.org
Why a webhook beats polling for ranking drops
Rankings only change when a check finishes, so a script that polls the API every few minutes mostly fetches data it already has. It also spends request quota: the API has monthly call allowances (100,000 on Growth, 500,000 on Pro, 2,000,000 on Agency) and per-minute rate limits, and polling uses them for nothing.
A webhook reverses this. TrackSERPs sends a signed HTTP POST to your endpoint when a run finishes or an alert fires, so your code runs once per event. Webhook endpoints need Growth or higher (2 on Growth, 5 on Pro, 20 on Agency); Starter has none. The rest of this guide covers the payload, signature check and a Slack example.
Complete webhook implementation workflow
Setting up secure, automated ranking drop webhooks involves five technical steps:
Register a webhook endpoint in Settings or via API
Navigate to Settings → API → Webhooks in your TrackSERPs dashboard (or call
POST /v1/webhooks). Enter your destination HTTPS URL (e.g.,https://api.example.com/webhooks/trackserps) and select the events to subscribe to:alert.triggeredandrankings.updated. Copy your endpoint signing secret (whsec_...) immediately.Configure ranking drop alert rules in the dashboard
In Alerts → Create Alert Rule, define your drop criteria:
- Trigger condition: Rank dropped by more than 3 positions, or dropped out of the top 10.
- Scope: All project keywords, or filtered by specific tags (e.g.,
commercial). - Destination: Check your registered webhook endpoint.
Parse the incoming TrackSERPs-Signature header
When TrackSERPs delivers an event, inspect the
TrackSERPs-SignatureHTTP header. The header contains two comma-separated components: the unix timestamptand the hexadecimal HMAC-SHA256 signaturev1:TrackSERPs-Signature: t=1762862400,v1=5d41402abc4b2a76b9719d911017c592...Validate timestamp freshness and compute expected signature
Extract
tand verify that|currentTime - t| <= 300seconds to reject replay attacks. Compute the HMAC-SHA256 of"${t}.${rawBody}"using your endpoint secret and compare it againstv1using constant-time equality comparison.Acknowledge with HTTP 200 and process payload asynchronously
Return an HTTP
200 OKor204 No Contentwithin 5 seconds. Dispatch background jobs to notify your team via Slack, PagerDuty, or SMS.
Node.js signature verification with @trackserps/sdk
The official @trackserps/sdk provides a built-in verifyWebhook helper that implements RFC-compliant signature verification, constant-time comparison, and timestamp tolerance checking:
import express from "express";
import { verifyWebhook } from "@trackserps/sdk";
const app = express();
const WEBHOOK_SECRET = process.env.TRACKSERPS_WEBHOOK_SECRET!; // whsec_...
// Express requires raw body for HMAC verification
app.post(
"/webhooks/trackserps",
express.raw({ type: "application/json" }),
(req, res) => {
const signatureHeader = req.headers["trackserps-signature"] as string;
const rawBody = req.body.toString("utf8");
// 1. Verify signature and 300s timestamp freshness
const isValid = verifyWebhook(rawBody, signatureHeader, WEBHOOK_SECRET, {
toleranceSeconds: 300,
});
if (!isValid) {
console.warn("Invalid webhook signature or expired timestamp");
return res.status(401).json({ error: "Invalid signature" });
}
// 2. Parse payload and process event
const event = JSON.parse(rawBody);
console.log(`Received verified event: ${event.event} (${event.id})`);
if (event.event === "alert.triggered") {
const { phrase, previous_rank, current_rank, delta, ai_overview } = event.data;
console.warn(
`🚨 RANK DROP ALERT: "${phrase}" fell from #${previous_rank} to #${current_rank} (Δ: ${delta})`
);
if (ai_overview?.present && !ai_overview?.cited) {
console.warn(`⚠️ Generative impact: Domain not cited in active AI Overview`);
}
}
// 3. Return 200 OK immediately
return res.status(200).json({ received: true });
}
);
app.listen(3000, () => console.log("Webhook receiver listening on port 3000"));
Python signature verification using hmac and hashlib
For Python backends (FastAPI, Flask, Django), verify webhook signatures using standard library modules:
import hmac
import hashlib
import time
import json
from flask import Flask, request, jsonify
app = Flask(__name__)
WEBHOOK_SECRET = "whsec_live_example_secret_for_tutorials_98765432"
def verify_trackserps_webhook(
raw_body: str,
sig_header: str,
signing_secret: str,
tolerance_seconds: int = 300
) -> bool:
"""Verifies TrackSERPs webhook signatures and timestamp freshness."""
if not sig_header or not signing_secret:
return False
try:
parts = dict(part.strip().split("=") for part in sig_header.split(","))
t_str = parts.get("t")
v1_sig = parts.get("v1")
if not t_str or not v1_sig:
return False
# Reject replay attacks older than tolerance window
timestamp = int(t_str)
if abs(int(time.time()) - timestamp) > tolerance_seconds:
return False
# Compute expected HMAC-SHA256 signature
signed_payload = f"{timestamp}.{raw_body}".encode("utf-8")
expected_sig = hmac.new(
signing_secret.encode("utf-8"),
signed_payload,
hashlib.sha256
).hexdigest()
# Constant-time comparison to prevent timing attacks
return hmac.compare_digest(v1_sig, expected_sig)
except Exception:
return False
@app.route("/webhooks/trackserps", methods=["POST"])
def handle_webhook():
sig_header = request.headers.get("TrackSERPs-Signature", "")
raw_body = request.get_data(as_text=True)
if not verify_trackserps_webhook(raw_body, sig_header, WEBHOOK_SECRET):
return jsonify({"error": "Unauthorized"}), 401
payload = json.loads(raw_body)
event_type = payload.get("event")
if event_type == "alert.triggered":
data = payload.get("data", {})
phrase = data.get("phrase")
prev = data.get("previous_rank")
curr = data.get("current_rank")
print(f"RANK ALERT: '{phrase}' dropped from #{prev} to #{curr}")
return jsonify({"received": True}), 200
if __name__ == "__main__":
app.run(port=5000)
Structure of the alert.triggered payload
When an alert condition fires, TrackSERPs dispatches a structured JSON payload:
{
"id": "evt_test_rank_drop_991",
"event": "alert.triggered",
"created_at": "2026-11-11T12:00:00.000Z",
"data": {
"rule_id": "rule_top10_drop",
"rule_type": "rank_dropped",
"project_id": "cmwc18tij0005rquydas1a5z5",
"phrase": "emergency plumber chicago",
"device": "desktop",
"previous_rank": 3,
"current_rank": 12,
"delta": -9,
"ai_overview": {
"present": true,
"cited": false,
"cited_url": null
}
}
}
| Capability | Security Requirement | Specification | Protection Goal |
|---|---|---|---|
| Algorithm[1] | HMAC-SHA256 | Guarantees payload authenticity and integrity | |
| Timestamp Validation[2] | t parameter (<= 300s window) | Protects against network replay attacks | |
| Secret Rotation | Dual v1 signatures during 24h grace | Allows zero-downtime key rotation in production | |
| Delivery Retry Policy | Exponential backoff up to 72 hours | Protects against temporary endpoint downtime |
- https://www.rfc-editor.org/rfc/rfc2104 (checked 2026-11-11)
- https://www.rfc-editor.org/rfc/rfc9110 (checked 2026-11-11)
Best practices for webhook infrastructure
To ensure mission-critical alerting reliability:
- Use secret rotation grace windows: When rotating your webhook secret in Settings → API → Webhooks, TrackSERPs transmits both the new and old signatures for 24 hours. Pass an array of secrets (
[newSecret, oldSecret]) during deployment to achieve zero dropped events. - Process payloads asynchronously: Acknowledge the HTTP request immediately with a 200 OK response, then enqueue processing onto Celery, BullMQ, or SQS queues. Long-running notification workflows should never block the webhook response.
- Set up dead-letter alerts: Monitor endpoint delivery failure rates in the TrackSERPs deliveries view (
/v1/webhooks/{id}/deliveries) to spot failing endpoints before critical alerts are missed.
For detailed documentation on webhook payloads, review our webhook API reference, or explore our guide to building custom rank dashboards.
Frequently asked questions
What event types do TrackSERPs webhooks emit?
How is the TrackSERPs-Signature header structured?
How do I prevent replay attacks on webhook endpoints?
What should my webhook endpoint return after receiving a payload?
Sources & references
- RFC 2104 — HMAC: Keyed-Hashing for Message Authentication(checked 2026-11-11)
- RFC 9110 — HTTP Semantics(checked 2026-11-11)
- OpenAPI Specification 3.1.0(checked 2026-11-11)
Get product updates and SEO tips
We will email you a link to confirm your address before anything else is sent.