Client Reporting
Compare weekly lead efficiency
Compare two supplied lead-generation windows without hiding zero denominators. Return cost per lead, lead change in basis points and an explicit decline or insufficient-data status.
Experimental native example · local preview · revision 1
WORKFLOW PREVIEW
See how it works
Use + and − to zoom, F to fit. Press Enter on a node to inspect it.
Private preview. These tested drafts are available for inspection. Adding them to a Vora workspace is still being tested.
What you need
- Two comparable reporting windows using the same lead definition, attribution basis and currency.
- Nonnegative integer spend minor units and lead counts, plus a positive drop threshold in basis points.
Follow the workflow step by step
Supplied agency data
Receive the explicitly supplied manual input packet.
- default: Compare weekly lead efficiency
Compare weekly lead efficiency
Return current and prior cost per lead, lead change basis points and a threshold flag from two supplied reporting windows. Missing denominators produce an explicit insufficient-data result; no causal claim or provider retrieval.
Setup and review
- Supply current and prior totals from a reconciled report.
- Test the decline threshold and a zero-lead window.
- Inspect null values and insufficient_data before adding the packet to a client report.
Inspect every node
Expand a node to inspect its complete settings. Review the runtime and adoption evidence before installing it.
Supplied agency data · wfManualTrigger
{
"label": "Supplied agency data"
}Compare weekly lead efficiency · code
{
"label": "Compare weekly lead efficiency",
"code": "\nfunction obj(value, keys, required = keys) {\n if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('Expected object');\n if (Object.keys(value).some(key => !keys.includes(key))) throw new Error('Unknown input field');\n if (required.some(key => !Object.hasOwn(value, key))) throw new Error('Missing required input field');\n return value;\n}\nfunction text(value, name, max = 200, allowEmpty = false) {\n if (typeof value !== 'string' || value.length > max || (!allowEmpty && !value.trim())) throw new Error('Invalid ' + name);\n return value.trim();\n}\nfunction list(value, name, max = 500) {\n if (!Array.isArray(value) || value.length > max) throw new Error('Invalid ' + name);\n return value;\n}\nfunction int(value, name, min = 0, max = Number.MAX_SAFE_INTEGER) {\n if (!Number.isSafeInteger(value) || value < min || value > max) throw new Error('Invalid ' + name);\n return value;\n}\nfunction amount(value, name) {\n if (!Number.isFinite(value) || value < 0 || value > 1000000000) throw new Error('Invalid ' + name);\n return value;\n}\nfunction email(value) { return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value); }\nfunction day(value) {\n if (typeof value !== 'string' || !/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) throw new Error('Invalid calendar date');\n const ms = Date.parse(value + 'T00:00:00Z');\n if (!Number.isFinite(ms) || new Date(ms).toISOString().slice(0, 10) !== value) throw new Error('Invalid calendar date');\n return ms;\n}\nfunction instant(value) {\n if (typeof value !== 'string' || !/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z$/.test(value)) throw new Error('Invalid UTC timestamp');\n const ms = Date.parse(value);\n const normalized = value.includes('.') ? value : value.replace('Z', '.000Z');\n if (!Number.isFinite(ms) || new Date(ms).toISOString() !== normalized) throw new Error('Invalid UTC timestamp');\n return ms;\n}\nfunction uniqueIds(items) {\n const ids = items.map(item => text(item.id, 'item ID', 120));\n if (new Set(ids).size !== ids.length) throw new Error('Duplicate item ID');\n return ids;\n}\nfunction ratioBps(numerator, denominator) {\n const n = BigInt(numerator) * 10000n;\n const d = BigInt(denominator);\n const quotient = n / d;\n const floor = n < 0n && n % d !== 0n ? quotient - 1n : quotient;\n const result = Number(floor);\n if (!Number.isSafeInteger(result)) throw new Error('Unsafe calculated ratio');\n return result;\n}\n\n\nconst x = obj(context.input, ['reportId','current','prior','alertDropBps']);\nconst reportId = text(x.reportId, 'report ID', 120);\nconst current = obj(x.current, ['spendMinor','leads']), prior = obj(x.prior, ['spendMinor','leads']);\nfor (const values of [current,prior]) { int(values.spendMinor, 'spend minor units'); int(values.leads, 'lead count'); }\nconst threshold = int(x.alertDropBps, 'drop threshold', 1, 10000);\nconst currentCostPerLeadMinor = current.leads ? Math.floor(current.spendMinor / current.leads) : null;\nconst priorCostPerLeadMinor = prior.leads ? Math.floor(prior.spendMinor / prior.leads) : null;\nconst leadChangeBps = prior.leads ? ratioBps(current.leads - prior.leads, prior.leads) : null;\nconst status = !current.leads || !prior.leads ? 'insufficient_data' : leadChangeBps <= -threshold ? 'decline' : 'within_threshold';\nreturn {reportId, currentCostPerLeadMinor, priorCostPerLeadMinor, leadChangeBps, status};\n",
"outputVar": "result",
"timeout": 1000,
"memoryLimit": 16
}Input and output contracts
Input
{
"type": "object",
"properties": {
"reportId": {
"type": "string",
"maxLength": 120
},
"current": {
"type": "object",
"properties": {
"spendMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"leads": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"spendMinor",
"leads"
],
"additionalProperties": false
},
"prior": {
"type": "object",
"properties": {
"spendMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"leads": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"spendMinor",
"leads"
],
"additionalProperties": false
},
"alertDropBps": {
"type": "integer",
"minimum": 1,
"maximum": 10000
}
},
"required": [
"reportId",
"current",
"prior",
"alertDropBps"
],
"additionalProperties": false
}Output
{
"type": "object",
"properties": {
"reportId": {
"type": "string",
"maxLength": 120
},
"currentCostPerLeadMinor": {
"type": [
"integer",
"null"
],
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"priorCostPerLeadMinor": {
"type": [
"integer",
"null"
],
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"leadChangeBps": {
"type": [
"integer",
"null"
],
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"status": {
"type": "string",
"maxLength": 24
}
},
"required": [
"reportId",
"currentCostPerLeadMinor",
"priorCostPerLeadMinor",
"leadChangeBps",
"status"
],
"additionalProperties": false
}Choose an output for this job
This business workflow also has 15 delivery formats. Compare their inputs, output examples and limits.
Example input and result
These examples use synthetic data.
Input
{
"reportId": "report-01",
"current": {
"spendMinor": 24000,
"leads": 8
},
"prior": {
"spendMinor": 20000,
"leads": 10
},
"alertDropBps": 1500
}Expected result
{
"reportId": "report-01",
"currentCostPerLeadMinor": 3000,
"priorCostPerLeadMinor": 2000,
"leadChangeBps": -2000,
"status": "decline"
}Success means: Return current and prior cost per lead, lead change basis points and a threshold flag from two supplied reporting windows. Missing denominators produce an explicit insufficient-data result; no causal claim or provider retrieval.
When something goes wrong
- Negative spend or fractional leads stops the calculation. Reconcile the source report and repeat. When either window has no leads, keep the insufficient-data result visible; do not substitute a fabricated percentage or cost per lead.
Limits and costs
- Cost per lead is rounded down to a whole minor unit; signed percentage changes round down to a basis point. This workflow retrieves no analytics data and makes no causal claim about campaign performance.
- No paid model calls or metered third-party operations are declared in this pure graph. Vora plan availability, compute and quotas still apply; pricing has not been verified by this batch.