Skip to main content

Page hooks

A page hook is a request that Webround makes to your server while a page of your site loads, before the content reaches the visitor. Your answer is injected into the page: dynamic data, a script, structured data, without touching the site's code.

The logic lives in your own system, not on Webround's: it is isolated from every other customer, and you can change it or turn it off whenever you want. All Webround needs is an address that answers.

Configure a hook​

ParameterDescription
URLThe address Webround calls.
MethodGET, POST, PUT, PATCH or DELETE.
BodyAn optional payload to send.
PagesThe pages it runs on, as patterns: *, /product/*.
Audienceall, human or bot. Useful for dynamic rendering.
TimeoutThe longest wait, from 500 to 10000 ms.
SecretIf on, Webround signs every request (HMAC-SHA256).
InjectWhere the answer goes: see below.

What your server answers​

Always a JSON object with a data field:

{ "data": {} }

data is injected according to the hook's inject type:

TypeWhat happens
windowdata is available as window.__WR_APPS__["slug"], to any script on the page. The most common.
head-scriptdata is added as a <script> in the <head>.
head-styledata is added as a <style> in the <head>.
json-lddata is added as <script type="application/ld+json"> in the <head>.
body-startdata is added right after <body>.
body-enddata is added before </body>.
// In your site
const reviews = window.__WR_APPS__["trustpilot"];
console.log(reviews.average); // 4.7

Verify the signature​

With a secret, Webround generates a random key when you create the hook and shows it once. Every call has these headers:

X-WR-Timestamp: 1745000000
X-WR-Signature: t=1745000000,v1=a3f9c2...

The signature is HMAC-SHA256(secret, "{timestamp}.{METHOD}.{pathname}.{body}"), where body is the payload of the request, or an empty string if there is none. Check it, and refuse requests older than 30 seconds: that stops anyone who intercepts a request from sending it again.

export default {
async fetch(request, env) {
const timestamp = request.headers.get('X-WR-Timestamp');
const match = request.headers.get('X-WR-Signature')?.match(/t=(\d+),v1=([a-f0-9]+)/);
if (!timestamp || !match) return new Response('Missing signature', { status: 401 });
if (Math.abs(Math.floor(Date.now() / 1000) - parseInt(timestamp)) > 30) return new Response('Timestamp expired', { status: 401 });

const body = request.method === 'GET' ? '' : await request.text();
const payload = `${timestamp}.${request.method}.${new URL(request.url).pathname}.${body}`;
const key = await crypto.subtle.importKey('raw', new TextEncoder().encode(env.HOOK_SECRET), { name: 'HMAC', hash: 'SHA-256' }, false, ['verify']);
const signature = Uint8Array.from(match[2].match(/.{2}/g).map((byte) => parseInt(byte, 16)));
if (!(await crypto.subtle.verify('HMAC', key, signature, new TextEncoder().encode(payload)))) {
return new Response('Invalid signature', { status: 401 });
}

const data = { /* your data */ };
return new Response(JSON.stringify({ data }), { headers: { 'Content-Type': 'application/json' } });
},
};

Example: reviews on product pages​

You want to show review data on product pages without calling the review service from the browser, which would expose your credentials. Create a hook that points to an endpoint of yours:

URLhttps://hooks.example.com/trustpilot
MethodGET
Injectwindow
Pages/product/*
Audiencehuman
Secreton

The endpoint answers { "data": { "average": 4.7, "count": 128 } }, and on the site window.__WR_APPS__["trustpilot"] has it. With the human audience, bots do not get it: it does not affect SEO, because what Google needs (name, price, description) is already in the page.

Your endpoint can be built however you like: a Cloudflare Worker, a container on your own server, Google Cloud Run or a service that wraps a public API. Webround only calls it, verifies the answer and injects it.

Manage your hooks​

In your Webround account, open the Draft tab, choose the draft and click Manage integrations .

Webround Draft Integration Manager

Click "Manage integrations" to manage the integrations of this draft.

Use the form to add, change or delete a hook.

Webround Draft Hook Manager

Save the hook: it starts injecting data on the public site right away.