Skip to main content

How are custom metrics calculated?

Understand more detail on when and how formula and rules are evaluated

Rules are run at the data source level-of-detail (a row-level calculation). One can think of it as a conditional calculation of a new column done per Data Source row.

​

The results are then aggregated to create the query result. The following aggregation types are supported:

​

  • Sum - add all values to a total

  • Count - adds up the rule value for each source row, the same way as Sum. A rule that returns 1 counts rows. It does not count unique values. See the section on counting unique values below.

  • Min - lowest value per source row

  • Max - highest value per source row

  • None - does not sum values. What are non-aggregatable metrics?

​

Formula are calculated at the visualisation level-of-detail (an aggregate calculation) after summarising. These are also used to calculate totals and can thus also correctly calculate rate and ratios between other metrics.

​

To illustrate this, imagine a simple Funnel Workspace with one Facebook and one Google Analytics account. In this Workspace we have created a custom rule based metric for Cost that uses Spend metric for Facebook and for Google Analytics we multiply any affiliate conversion with 1 dollar. There is also a formula based metric, CPC, that divides the custom Cost with Clicks.

​

To provide a result showing Cost and CPC per Campaign Funnel would:

​

  1. For Facebook data, apply Cost rules

    ​

  2. For Google Analytics data, apply Cost rules

    ​

  3. Summarise data from all data sources per Campaign

    ​

  4. On the aggregated data apply CPC formula

    ​

  5. Re-apply CPC formula for totals or other visualisation

​

Note that formula based metrics in visualisations can not always be calculated in correct order after other formulas are calculated, depending on where this formula is applied. It is therefore not possible to use a formula in another formula. However, since rule based metrics are calculated before formulas they can depend on other aggregatable metrics and be used in formulas.

​

Can I count unique values, like the number of campaigns?

No. Metrics are added up from data source rows, and no aggregation type counts distinct values. A campaign usually has one row per day, and more rows for other breakdowns such as country or ad. A metric that returns 1 for each row counts those rows, not campaigns, so the number is much higher than the real campaign count.

​

A rule metric that returns 1 per row gives a correct count only when each row is one item, for example one order.

​

To find out how many campaigns (or ads, or other dimension values) match your filters:

​

  • Data Explorer or a dashboard table: group by Campaign only, with your date range and filters, and count the rows. Each row is one distinct Campaign value, so campaigns that share a name count once.

  • Funnel AI: ask, for example, "How many campaigns with Brand in the name ran last month?". Funnel AI can count them for you.

  • Data warehouse or BI tool: export the data and use COUNT(DISTINCT ...) there if you need the count as a single number in reports.

​

Metrics such as Users or Reach are unique counts that the platform calculates. You can use them, but they can't be summed across days or campaigns. See What are non-aggregatable metrics?

Did this answer your question?