A usage metric is a formula that aggregates a set of events into a single number representing total usage. To create a usage metric in the Sequence dashboard, click “Add new” and select “Usage metric”:

Give the metric a name and the type of usage events you want to aggregate – this should match the eventType in the usage event object.

All text matching in Sequence is case-sensitive. Make sure you use the same cases for event types in your usage event and metrics, and for customer aliases in your usage events and customers.

Then select how you want to aggregate the events; Sequence currently supports 3 aggregation types:

Aggregation typeRequires aggregation propertyDescriptionSQL equivalent
COUNTnoTotal number of eventsCOUNT(*)
SUMyesSum of a numeric property(1)(^1)SUM(properties[‘property_name’])
UNIQUEyesCount of unique values of a propertyCOUNT(DISTINCT properties[‘property_name’])

SUM and UNIQUE require you to specify an event property as the argument of the aggregation, enter the name of this property in the “Aggregation property” field.

When the billing engine runs, it calculates all usage metrics for each of your customers over the last billing period. This calculated value is then combined with a price to determine the charge that will appear on the invoice.

1: Numerical values (such as transaction amount, duration, size, etc) must conform with ISO 31-0.

Filtering

You can further refine the scope of a usage metric using filters. A filter limits the aggregation input to events that match a specific event property value. For example, if your events have a property called method, you can filter your metric to events where method = card_payment:

If multiple filters are specified, only events matching all filters are included in the metric calculation.

Grouping

Use grouping to customize the layout of a usage-based charge on an invoice by breaking down usage by an event property. For example, grouping by method will let you display the usage for method = card_payment and method = direct_debit on separate lines on the invoice. To learn more about customizing your invoice layout via grouping, reach out to the Sequence team.

Editing metrics

Updating and deleting usage metrics is currently only supported via the API. Making changes to a metric will not retroactively affect invoices already created. To update or correct existing invoices after changing a metric, recalculate a draft invoice, or issue a credit note against an issued invoice.

Usage calculation period

When your pricing includes graduated usage tiers, you can just the usage calculation period to achieve more advanced usage based pricing scenarios, such as billing for monthly overages over an annual running total of customer usage.

Options:

  • Billing period (default): Usage is calculated for each billing period.
  • Cumulative usage: Usage is counted from the billing schedule start date and accumulates with each billing period.
  • Quarter: Usage is counted over a quarterly period. Tiers in each billing period are based on quarterly usage.
  • Annual: Usage is counted over an annual period. Tiers in each billing period are based on annual usage.

Custom metrics

Sequence supports custom usage metric formulas and parameters for more advanced usage aggregation scenarios. Ingest raw usage data and let Sequence handle complex data mapping and calculation logic. Speak to our team to learn more about custom metrics.

Custom metrics: Custom metrics allow for advanced usage aggregations expressed as formulas.

Parameters: Parameters can be used in custom metrics as variables that can be set when a price is configured for a customer. For example, if you have a custom metric to calculate a ratio, you can optionally include a parameter to set the specific ratio on a per-customer basis.