View as Markdown

Identify · Guide

Check storefront visitors

Load the storefront check on your store's pages and Identify classes every visitor that runs the page's scripts: a person, a signed agent, an unsigned agent, an automated browser. On the cart and checkout pages you get a visit ID to pass with your checkout assessment, so your checkout rules read who was at the till. Field timing, off until you turn it on, adds how the checkout form was filled in.

Before you begin: a publishable key for your site (Developers › Publishable keys in the console, or the call in step 1). On Shopify, install the Provenance app instead and follow Hold Shopify orders. On WooCommerce, the Provenance for WooCommerce plugin checks requests on your server and loads the script for you: follow Hold WooCommerce orders. Every plan; each cart or checkout page view is one hosted check, and other page views are free.

  1. The page loads the script
    one event per page view
  2. Identify classes the visit
    a person, an agent or a bot
  3. Your checkout passes the visit
    your rules read it

1. Create a publishable key

A publishable key names your site in the browser. List your site's origins in allowed_origins, so a copy of the key on another site is refused.

export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5

export PUBLISHABLE_KEY=$(curl -s -X POST $PROVENANCE_API/v1/embed/publishable_keys -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" -d '{ "name": "Storefront" }' | jq -r .publishable_key)
echo "{\"publishable_key\": \"$PUBLISHABLE_KEY\"}"
{ "publishable_key": "prv_pub_9cK2mW7xT4vQ8nB3sYd6fJh1gAe5rLp0" }

2. Add the script to your pages

Put one tag in your pages' <head>. Tell the script which page it is on with data-provenance-page on <html>, for example checkout; without it, the script reads the path.

<html data-provenance-page="checkout">
  <head>
    <script type="module" src="https://sandbox-api.provenanceauth.com/v1/identify/storefront.js?key=prv_pub_9cK2mW7xT4vQ8nB3sYd6fJh1gAe5rLp0" async></script>
  </head>
</html>

On each page view the script sends one event to POST /v1/identify/storefront_events: your key, the page type, a random ID for the page view and whether the browser is driven by an automation tool. Identify classes the event's own request (its address, its headers and any Web Bot Auth signature) and records it as the visit. This is what the script sends from a product page:

curl -s -X POST $PROVENANCE_API/v1/identify/storefront_events \
  -H "Content-Type: text/plain" \
  -d "{ \"key\": \"$PUBLISHABLE_KEY\", \"event\": \"page_view\", \"page\": \"product\", \"view_id\": \"Xq3bN8vR2mT6kW9yZc4dF7hJ\", \"webdriver\": false }"
{ "object": "storefront_event", "recorded": true, "reason": null, "visit_id": null }

A product page view is free and returns no visit ID. A cart or checkout page view is a hosted check and returns one, "visit_id": "tas_01KAG3W1Q9ZJ8M4V2T6X0YB7RC".

3. Pass the visit with your checkout

On cart and checkout pages the script gets a visit ID and puts it where your checkout can read it:

WhereWhat
<input name="provenance_visit">Any such input on the page gets the visit ID, so a form posts it with the order
<html data-provenance-visit>The visit ID, for your own script
provenance:visit eventSent on document with { visit_id }

Send it as visit_id with POST /v1/authorize/checkout_assessments. The assessment reads the visit's class and scores, so your checkout rules can ask about them. A visit is read for 24 hours.

4. Turn on field timing

Field timing watches how the checkout form is filled in, never what is typed, and turns it into an automation score from 0 to 100. Fast, pasted, pointer-free entry with machine-even key timing scores high; ordinary typing scores low. It is off until you turn it on.

curl -s -X PUT $PROVENANCE_API/v1/identify/settings/site \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "storefront": { "field_timing": true } }'
{ "object": "identify_config", "storefront": { "field_timing": true } }

Field timing runs only for visitors who allow analytics. When your consent banner records that choice, set window.provenanceConsent = { analytics: true } or send a provenance:consent event with { analytics: true }; until then nothing timing-related runs or is sent.

At the form's submit the script sends one summary for the visit:

MeasuredHow
Time to fillFirst focus on a field to submit, and each field's focus-to-blur time
How each value arrivedTyped, pasted or autofilled, from the input events
Typing rhythmThe count of key events and the mean and spread of the gaps between them
PointerCounts of pointer moves, clicks and touches
Generated eventsEvents the browser didn't make itself

Each field is named by its role only: email, name, phone, address, postal code, note or discount code. Card, password and one-time-code fields are never watched.

5. Write rules on it

Your checkout rules read these facts from the visit:

FactTypeWhat it is
agent.automation_scorenumberField timing's score, 0 to 100
agent.typedbooleanA field was typed in
agent.pointer_seenbooleanA pointer moved, clicked or touched
agent.fields_all_pastedbooleanEvery filled field was pasted
agent.checkout_fill_secondsnumberFirst focus to submit, in seconds
agent.typing_interval_msnumberThe mean gap between key events

With field timing off, without the visitor's consent, or on a page the script doesn't reach, these facts are absent and their conditions don't match.

Field timing never blocks on its own

A rule whose conditions are all field timing may ask the person or notify you, never reject or hold: the policy write refuses it with behaviour_only_reject until you add another condition.

6. Know what it sees

The script sees visitors that run the page's scripts: browsers, automated browsers and browser agents. A client that fetches pages without running scripts appears only through its orders. It sets no cookie, uses no storage and reads nothing about the device; addresses follow your Identify retention and pseudonym settings.

Field timing is a hint. Browser autofill and password managers fill fields in a fraction of a second; pasting an address from a note looks like an agent; voice input and other assistive tools produce unusual timing; a shopper on an accelerated checkout fills nothing in and sends no summary. An agent can also add pauses and type key by key. Ask the person on a high score rather than reject, and check the backtest before a rule goes live.

Errors you might see

SymptomCauseFix
403 embed_origin_not_allowedThe page's origin isn't in the key's allowed_originsAdd your site's origin to the key.
401 embed_token_invalidThe key is unknown, revoked or from the other environmentUse a live key on your live site.
recorded: false with plan_inactiveYour trial or allowance ended, so no verdict was madeUpgrade in Billing; the next page view records again.
recorded: false with field_timing_offField timing is offTurn it on (step 4).
404 resource_missing on a form submitThe visit isn't a storefront visit of this site, or it's over 24 hours oldSend the visit ID the page view returned.

See also