Run scripts inside a secure sandbox to transform HTML and control behavior in real time — between the server and the user.
Rules handle 80% of what you need — declaratively, without code. Scripts handle the rest: complex transformations, dynamic calculations, multi-step logic that rules can't express in a single action.
If rules define what happens — scripts define exactly how.
Every script runs inside a controlled, isolated sandbox. It can transform HTML and read request context — but it cannot access the underlying system, make arbitrary network calls, or affect anything outside the current response.
ctx.request.ctx.variables — ready to use in script logic.ctx.html.ctx.response.Scripts give you full programmatic control over the HTML response — without a backend, without a deploy.
Set titles, headings, meta tags, and any element's content or attributes programmatically.
<title> dynamically<meta> tagshref, src, data-*Build HTML strings from data and inject them into any position in the page.
Compute, format, and combine values from datasets before injecting them into output.
Branch behavior based on runtime context — URL, headers, variables — with full if/else control flow.
Every script receives a ctx object — the full runtime context for the current request. It's how your script reads data, reads the request, and writes back to the response.
Everything about the incoming HTTP request — URL, path, query params, method, user agent.
All variables resolved from the active dataset for this request, ready to use in script logic.
A structured API to read and modify the HTML response — titles, meta, elements, attributes.
Set or modify HTTP response headers, cache directives, and status codes for the current request.
The detected country, region, and city of the requesting user — inferred at the edge from the IP.
Device type and browser category — use it to deliver different output for mobile vs desktop.
A script that generates a dynamic SEO title and meta description from dataset variables and geo context — then injects them into the HTML response before delivery.
Scripts are not standalone. They're always invoked from within a rule — using the run_script action in the DO block. This means scripts inherit the rule's conditions, matching context, and security scope.
Compute unique title and meta description per city, product, or segment — combining dataset values with geo context and formatting logic.
Apply multi-condition logic — device + geo + returning user — to select and inject the right content block for each unique combination.
Reformat prices, dates, or text for the target locale — apply number formatting, currency symbols, and language conventions to dataset values.
Show or hide UI elements — banners, CTAs, notices — based on runtime conditions computed in the script, not in JavaScript on the client.
Implement multi-variant logic beyond simple A/B — weighted allocation, holdout groups, and contextual assignment — all computed at the edge.
Generate and inject JSON-LD schema, Open Graph tags, and canonical URLs computed from dataset values — per page, per product, per city.
Rules and scripts are complementary — not competing. Use rules for most things. Add scripts when you need the extra degree of control.
| Dimension | Rules | Scripts |
|---|---|---|
| Style | Declarative — describe what to do | Imperative — write how to do it |
| Complexity | Simple, single-step logic | Multi-step, conditional, computed logic |
| Coding required | No-code — visual configuration | Low-code — lightweight JS-like syntax |
| Setup time | Fast — define and activate immediately | Short development cycle — test in sandbox |
| Flexibility | Covers most standard use cases | Handles any logic that rules cannot express |
| Execution | Resolved inline by the rule engine | Run in isolated sandbox per request |
| Best for | SEO, redirects, header injection, A/B splits | Dynamic SEO, complex personalization, data transformation |
Add script actions to any existing rule — without changing how it matches or triggers.
Write the exact logic your use case needs — not a workaround that approximates it.
From simple string formatting to multi-step conditional branching — scripts cover it all.
Products change, sites evolve. Scripts let you adapt delivery logic without touching the origin.
You write the logic. The edge executes it —
between the server and the user.
Extend your rules with custom scripts. Run logic safely at the edge — no backend changes, no deployment, no risk.