Users and the control group
User ID
Section titled “User ID”user_ref is your internal user ID: Latin letters, digits and _ . : -, up to 128 characters. Do not send an email, a phone number or other personal data: we don’t need them.
No need to create users in advance
Section titled “No need to create users in advance”The first event with a new user_ref creates the user, and no progress is lost. Use POST /v1/users when you want to pass attributes right away or show the program to someone who hasn’t done anything yet.
POST /v1/usersContent-Type: application/json
{ "user_ref": "s_81c3", "attributes": { "seller_type": "private" } }The response is 201 for a new user and 200 if the user already existed: then the attributes are simply applied. Retrying is safe.
Attributes
Section titled “Attributes”Attributes select scenario audiences: for example, a scenario for private sellers only looks at seller_type. We accept only attributes known to your dictionary or to scenario audiences. Others are dropped without an error.
There are two ways to change an attribute:
PATCH /v1/users/{user_ref}withContent-Type: application/merge-patch+json. A passed value replaces the old one,nullremoves the attribute.- An event field, if the dictionary marks that field as a user attribute. Then the value applies from the event’s
occurred_at.
PATCH /v1/users/s_81c3Content-Type: application/merge-patch+json
{ "attributes": { "seller_type": "dealer" } }The latest value in time wins. The first known value also applies backwards, so history counts toward scenarios of its audience. Changing an attribute does not break attempts already in progress: the audience is checked at the moment of the event that opened the attempt.
Control group
Section titled “Control group”To measure the program’s effect honestly, some users don’t see it. That is the control group.
- Each scenario has its own control share. For example, 50% for scenarios for private sellers and 0% for dealers.
- Whether a user is in control for a scenario is decided by a hash of their
user_ref. It does not depend on events or time, so a user’s group per scenario never changes. - The
groupfield in responses sums up the active scenarios whose audience the user is in right now.controlmeans they are in control for all such scenarios;participantmeans they take part in at least one.
flowchart LR
u["User"] --> h{"hash of user_ref<br/>below the scenario's<br/>control share?"}
h -- yes --> c["control for the scenario:<br/>no progress or rewards"]
h -- no --> p["participant:<br/>progress, rewards, webhooks"]
What the site does with group: control:
- don’t show progress, the widget or program banners;
- show previously issued rewards and badges as usual: they stay;
- send events as for everyone else: we measure the effect from them.
Deleting on a user’s request
Section titled “Deleting on a user’s request”If a person asks to delete their data, call DELETE /v1/users/{user_ref}. The response is 204, and retrying is safe.
- The user is no longer visible: their
user_refbecomesnullin events and rewards. - Their discounts are frozen as they were: reservations, redemptions and releases no longer change them.
- If an event with the same
user_refarrives later, a new user starts from scratch, but in the same control groups.