Features
Webhooks: payment and goal alerts as signed JSON
A webhook sends every alert you pick to your own URL as JSON: the amount, currency, source, landing page and country of a payment, the goal and where the visitor came from, a traffic spike or a weekly report. Each request is signed so you can check it came from MetricRaven. It’s one of the alert channels.
Set it up
Add the webhook
In Settings → Notifications under Alert channels (or Settings → Integrations → Webhooks), choose Add channel, pick Webhook and paste your
https://URL. Admins and the owner can do this.Copy the signing secret
MetricRaven shows a secret starting with
whsec_once. Store it with your endpoint. Edit → New signing secret replaces it; the old one stops working at once.Choose what it receives
Tick Traffic spikes, Weekly report or Monthly report on the channel, and tick the webhook under And post to on each conversion alert (a payment, a new customer or a goal) it should receive.
Verify it works
Send test posts a test event and shows whether your endpoint answered with a 2xx status, or the status and the start of its answer.
Webhook payload
Every webhook request is a POST with a JSON body. The shape is stable: fields are only ever added, and version changes if one is ever removed or renamed.
| Header | Value |
|---|---|
| Content-Type | application/json |
| X-MetricRaven-Event | The event type, as in type below. |
| X-MetricRaven-Delivery | The event ID (same as id in the body). |
| X-MetricRaven-Timestamp | When it was sent, in Unix seconds. |
| X-MetricRaven-Signature | sha256= followed by the hex HMAC-SHA256 of "<timestamp>.<raw body>", keyed with your signing secret. |
| type | When |
|---|---|
| alert.payment | A payment, renewals included (alert trigger Any payment). |
| alert.new_customer | A customer’s first payment. |
| alert.goal | A goal was completed. |
| alert.digest | A busy alert’s hourly summary: data.count, data.from, data.to and up to 25 data.conversions in the same shape as a single alert’s data. |
| traffic.spike | A traffic spike: data.visitors, data.usualPerHour, data.ratio, data.sources, data.pages. |
| report.weekly / report.monthly | The report: data.period, data.currency, data.current (visitors, revenue, payments, conversionRate…), data.change, data.channels, data.referrers, data.pages, data.countries. |
| test | Send test. |
{
"id": "evt_3f9c2a7b1d0e4c5a9b8e7f60",
"type": "alert.payment",
"version": 1,
"occurredAt": "2026-11-20T10:04:12.000Z",
"site": { "id": "ana_pub_…", "name": "Acme", "domain": "acme.com" },
"alert": { "id": "6727c0f1a2b3c4d5e6f70812", "name": "New payment" },
"data": {
"kind": "payment",
"goalName": null,
"goalLabel": null,
"occurredAt": "2026-11-20T10:04:12.000Z",
"amount": 49,
"currency": "USD",
"plan": "Pro",
"renewal": false,
"customer": "Ana (ana@example.com)",
"channel": "Organic Search",
"source": "Google",
"campaign": null,
"landingPage": "/pricing",
"page": "/checkout",
"country": "ES",
"city": "Madrid",
"device": "desktop",
"browser": "Chrome",
"os": "macOS",
"visits": 3,
"firstSeenAt": "2026-11-18T09:00:00.000Z",
"journeyUrl": "https://metricraven.com/app/ana_pub_…?visitor=…"
}
}| Field | Meaning |
|---|---|
| id | Unique per event and endpoint, and the same if a send is retried: store it and skip duplicates. |
| occurredAt | When the conversion happened (for summaries, the latest one; for spikes and reports, when it was sent). |
| data.amount, data.currency | The payment in its own currency (null for goals). |
| data.source, data.channel, data.campaign | Where the converting visit came from: UTM source, ref or referrer, its channel, and utm_campaign. |
| data.landingPage, data.page | The visit’s first page and the page where it converted. |
| data.country, data.city | ISO country code and city. |
| data.customer | Name and email when you identify users, otherwise null. |
| data.journeyUrl | Opens that visitor’s journey in the dashboard (members only). |
Verify the signature
Compute the HMAC over the timestamp, a dot and the raw body exactly as received (before any JSON parsing), compare it in constant time, and refuse requests older than five minutes.
import crypto from "node:crypto";
import express from "express";
const app = express();
const secret = process.env.METRICRAVEN_WEBHOOK_SECRET; // whsec_…
app.post("/metricraven-webhook", express.raw({ type: "application/json" }), (req, res) => {
const timestamp = req.get("X-MetricRaven-Timestamp") ?? "";
const signature = req.get("X-MetricRaven-Signature") ?? "";
const expected = "sha256=" + crypto.createHmac("sha256", secret).update(`${timestamp}.${req.body}`).digest("hex");
const fresh = Math.abs(Date.now() / 1000 - Number(timestamp)) < 300;
const valid =
signature.length === expected.length && crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
if (!fresh || !valid) return res.status(401).end();
const event = JSON.parse(req.body.toString("utf8"));
if (event.type === "alert.payment") console.log(event.data.amount, event.data.currency, "from", event.data.source);
res.status(204).end();
});import hashlib, hmac, os, time
from flask import Flask, abort, request
app = Flask(__name__)
SECRET = os.environ["METRICRAVEN_WEBHOOK_SECRET"].encode() # whsec_…
@app.post("/metricraven-webhook")
def metricraven_webhook():
timestamp = request.headers.get("X-MetricRaven-Timestamp", "")
signature = request.headers.get("X-MetricRaven-Signature", "")
raw = request.get_data() # the raw bytes, not request.json
expected = "sha256=" + hmac.new(SECRET, timestamp.encode() + b"." + raw, hashlib.sha256).hexdigest()
if not timestamp.isdigit() or abs(time.time() - int(timestamp)) > 300:
abort(401)
if not hmac.compare_digest(signature, expected):
abort(401)
event = request.get_json()
if event["type"] == "alert.new_customer":
print("New customer:", event["data"]["amount"], event["data"]["currency"])
return "", 204Zapier, Make and n8n
All three take the webhook as is. Add a channel of type Webhook with the URL they give you, then press Send test so they can see a sample.
| Tool | Recipe |
|---|---|
| Zapier | Trigger: Webhooks by Zapier → Catch Hook. Copy the hook URL into MetricRaven, press Send test, then Test trigger in Zapier. Add a Filter step on type (for example only alert.payment) and map data.amount, data.source and data.country into Google Sheets, HubSpot or a Slack DM. |
| Make | Add a Webhooks → Custom webhook module, copy its address into MetricRaven and press Send test so Make learns the structure. A Router on type sends payments to your CRM and new customers to an email or Sheets module. |
| n8n | Add a Webhook node (POST, Raw body on), use its production URL in MetricRaven, and follow it with a Code or Crypto node that checks X-MetricRaven-Signature as shown above, then an IF node on type. |
Zapier and Make don’t check signatures by themselves. The URL they give you is the secret there: anyone who has it can post to your Zap or scenario, so don’t share it.
Troubleshooting
| You see | What to do |
|---|---|
| The endpoint answered 4xx or 5xx | Your server refused or failed the request. Check its logs; answer 2xx within 5 seconds and do slow work afterwards. |
| Timed out after 5 s | Answer first, then process the event in the background (a queue or a background job). |
| Answered with a redirect | Redirects aren’t followed. Use the final URL, usually with or without www or a trailing slash. |
| … points to a private or local address | Webhooks only go to public internet addresses. Expose the endpoint publicly (for local testing, a tunnel such as ngrok or Cloudflare Tunnel). |
| Signature doesn’t match | Sign the raw body exactly as received, before parsing JSON, prefixed with the timestamp and a dot; and use the latest secret if you made a new one. |
| The same event twice | Rare, after a retry. Store id and skip ids you have seen. |
A failed delivery doesn’t stop the other channels or the alert’s emails, and the next alert tries again. The error stays on the channel’s row until a delivery works.