Examples

For a discount-rate flag with variants 0%, 20%, and 30%, impressions are logged when users see the applied discount, and events are tracked when they complete a purchase.

// Step 1: Log impression

const discountRate = client.flag('discount-rate', 0.00);


// Step 2: Track the purchase event

const item = {

  productId: '0x123',

  price: 50.00,

  discount: discountRate // 0.3 (30%)

};

client.track('purchase_event', null, item);

Average or Sum Purchase Price

Let’s explore how an average or sum metric tracks purchase value for the discount-rate flag, testing which variant drives higher spending:

1

Set It Up

Select purchase_event and enter price as the value field to aggregate:

  • Events auto-populate from client.track().
  • Property Events let you derive multiple metrics from one purchase_event.
Metric event value selection
2

Choose Aggregation Method

Aggregate by average or sum:

Numeric metric aggregation selection
3

Interpret Experiment Results

See a simulated FlagSync dashboard for the discount-rate experiment, testing how discount variants impact average purchase value:

Simulated dashboard showing average purchase value for discount-rate variants
  • Trend: The chart shows 30% (pink) leading at $147 average purchase value, followed by 20% (orange) at $108, with 0% (blue) at $83.

The 30% variant is the clear winner, increasing average purchase value by 76.4% over the baseline.

Next Steps