Attribute Rules and Bucketing on a Customer ID

Learn how to choose who a server-assigned experiment enrols with attribute rules, and whether it buckets on the visitor ID or your own customer ID.

3 min read


With Assignment: Server, page targeting does not apply. Two settings on the experiment's settings tab decide who is enrolled and what keeps them on the same variant.

Bucket on

What decides the variant. The same ID always gets the same variant.

  • Visitor ID: the Pertento visitor ID, one per browser. Your backend stores it and sends it back on every request.
  • Customer ID: your own ID for a signed-in customer, so they see the same variant on every device.

Bucket on can only be changed while the experiment is a draft.

Bucketing on a customer ID

Pass your ID as id:

const decision = await pertento.getVariant('pricing-page', { id: String(user.id), visitorId });
const seed = pertento.seedScript([decision], visitorId);
  • IDs are exact. Cust-1 and cust-1 are two different people. Send exactly the same string every time, without trimming, lowercasing or reformatting it. An ID is at most 256 characters.
  • Pertento never stores your customer ID. It derives an enrolment ID from it with the website's secret salt, and enrols and counts that instead.
  • Use opaque IDs. The enrolment ID is pseudonymous, not anonymous: anyone holding a server key can derive it from a customer ID they can guess. Send a UUID or a keyed hash of your internal ID rather than a sequential number.
  • Counts differ by kind. A customer ID experiment counts customers, and a visitor ID experiment counts browsers. Compare variants within one experiment, not totals across the two kinds.
  • Pass the kind the experiment expects. With only a visitor ID, a customer ID experiment answers control with the reason wrong-id-kind, and the other way round. Passing both is fine: each experiment uses its own kind.

Attribute rules

Only visitors whose attributes match every rule are enrolled. With no rules, everyone is. Your backend passes the attributes with each decision:

await pertento.getVariant('new-checkout', { visitorId, attributes: { plan: 'pro', country: 'SE', cartValue: 640 } });

To add a rule, go to Attribute rules and choose Add rule. Pick the attribute, the operator, what to compare it as (Text, Number, or True or false) and the value. The operators are:

  • equals
  • is one of
  • is not one of
  • is less than
  • is greater than
  • exists

Things to know about rules

  • Every rule has to match. Rules are combined with AND.
  • A visitor without the attribute does not match a rule, except one that checks whether it exists.
  • Types are never converted. The text "5" does not match a rule on the number 5, so send numbers as numbers.
  • An experiment has at most 20 rules, and rules can be changed while it runs.
  • Attributes are a flat set of text, numbers, true or false, and lists of text or numbers.
  • When you report a conversion from your backend, send the same attributes you decided with. The rules are checked again, and different attributes can drop the conversion from the experiment. See Reporting conversions from your server.