Developers
Custom Outcomes
Quotes, booked calls, sign-ups: the results that matter to you, beside ad spend and sales, credited to the ad that brought them.
What An Outcome Is
An outcome is a result that matters to you and isn’t a store sale: a quote request, a booked call, a sample request, a sign-up. Each type you add gets its own columns in the Advertising report, beside ad spend and sales, and in your AI assistant’s cost_per_outcome tool. Stattery credits each one to the ad click before it, the same way it credits orders.
- Never added to sales. A quote isn’t money until it’s paid, so every outcome type is shown on its own: its count, its dollars if it has any, and dollars per $1 of ad spend (or the cost per one).
- Never sent to ad platforms. Send sales back sends real sales only.
- Email and phone are kept only as a one-way code (SHA-256). The tag codes them in the browser; from your server you can send them plain or already coded.
Set types up in Stattery: open the site, then Advertising in the left menu and the Outcomes tab. Each type has a name, says whether it has a dollar value, and says whether it’s a lead (not money yet) or a sale made outside the store. A site can have up to 20.
From The Page
With the Stattery tag on the page, one line records an outcome. Use the type’s code name, shown beside its name on the Outcomes tab.
stattery('outcome', 'quote', {
value: 1250, // dollars, for a type with a value
id: 'Q-1001', // your own id: sent again, it counts once
email: '[email protected]', // coded in the browser before it's sent
phone: '555-123-4567',
});
Everything after the type is optional. Without an id, the same visitor sending the same type within a minute counts once. A page can only add outcomes: changing one already recorded (its value, won or lost) takes your server and the outcome secret.
From Your Server Or A Form Tool
From your server, a CRM or a form tool such as Zapier or Gravity Forms, post to /outcome with the site’s outcome secret. Make it on the Outcomes tab; it is shown once, and making a new one stops the old one.
curl -X POST https://view.stattery.com/outcome \
-H "Authorization: Bearer YOUR_OUTCOME_SECRET" \
-H "Content-Type: application/json" \
-d '{ "site": "example.com", "type": "quote", "id": "Q-1001", "value": 1250, "email": "[email protected]" }'
Later, when you know, mark it won or lost by its id:
curl -X POST https://view.stattery.com/outcome \
-H "Authorization: Bearer YOUR_OUTCOME_SECRET" \
-H "Content-Type: application/json" \
-d '{ "site": "example.com", "type": "quote", "id": "Q-1001", "status": "won", "final_value": 1180 }'
| Field | What it is |
|---|---|
site | Required. Your site as added to Stattery. |
type | Required. The type’s code name. |
id | Optional but wise. Your own id. Sent again, it updates the same outcome. Needed to mark one won or lost. |
value | Optional. Dollars, for a type with a value. |
status, final_value | Optional. won, lost or open, and what it finally came to. |
email, phone | Optional. Coded with SHA-256 on arrival and never kept as written. Or send email_sha256 (of the lowercased address) and phone_sha256 (of the digits with the country code, such as 15551234567). |
visitor | Optional. The visitor id from the stt_v cookie the tag sets, to credit that browser’s ad click. |
time | Optional. When it happened, within the last 400 days: seconds or milliseconds since 1970, or an ISO date. |
The secret can also go in an x-stattery-secret header, or as ?secret= on the address for a tool that can’t set headers. A form post (application/x-www-form-urlencoded) works as well as JSON.
| Answer | Means |
|---|---|
200 { "ok": true, "id": 42, "ad": { "platform": "Google Ads", "campaign": "..." } } | Recorded, and the ad it was credited to (or null). |
200 { "ok": true, "updated": true } | An outcome with that id was already there and was updated. |
400 | Something’s missing, such as an id to mark won or lost, or the type reads the store’s own quotes. |
401 | The secret is wrong, or the site has none. |
404 | No such site, or no such outcome type on it. |
503 | Not saved. Send it again; with an id it won’t count twice. |
With No Code
Two rules need no code. Set them on the type in the Outcomes tab.
- Thank-you page. A visit reaching that page is one outcome, for example
/quote-thanks/. End it with*to cover everything under it. A reload within 30 minutes counts once. - Form. A CSS selector such as
#quote-formorform.contact. When a matching form on your site is sent, the tag records one outcome, with the form’s email and phone fields coded in the browser. The tag learns the rule from Stattery within a minute or so.
The store’s own quotes. A WooCommerce store using the Stattery plugin can count its quotes as a type: tick Count the store’s own quotes. Orders placed as quotes, or in a status mapped to Quote in Site Settings, Sales, count; paid ones show as won and cancelled ones as lost. One type per site can do this.
How Outcomes Are Credited
Each outcome is credited to the person’s first and last paid click, found by the same browser, the same email or the same phone number (from an earlier order or outcome). The report counts an outcome on the day it came in, under the network and campaign of the last click and the page it landed on. Spend And Results also groups outcomes by the month of the click, first click and last click. An open outcome is marked won when a paid order later comes from the same email or phone within 365 days.
Outcomes are kept for good, like every Stattery stat.