Emit custom metrics

This is for:

Developer

The emitMetric function allows you to emit custom experience metrics.

Note

You can track custom metrics in the same way as you track standard experience goals and custom goals.

Custom metrics are similar to custom goal events, except they aren’t tracked relative to the control. In other words, it’s an ideal way of tracking events that only happen as a result of the experience execution, for example, recommendation.clicked or experience-widget.opened.

Note

Custom metrics are saved in the BigQuery table event_qubit_metric.

The function takes three parameters:

  • type: The name of the metric being tracked

  • productId: Optionally bind this metric to a particular productId.

  • extra: Optionally provide extra info in an object that can contain arbitrary information to describe the metric (for example, product recommendations strategy).

Use the convention noun.verb for specifying type (for example, recommendation.clicked).

options.emitMetric('recommendation.clicked', productId)

The API is included in the options object passed to the variation or triggers functions and can be called as shown above.

Any events sent through this are bound to the experience they’re sent from.

Example:

options.emitMetric ('recommendation.shown', productId, {
  strategy: 'popular'
})