Skip to main content

Rule-based metrics

Rule-based metrics consist of one or more rules based on specific conditions (e.g. campaign name or data sources) or for all sources.

What is a rule-based metric?

A rule-based metric is a custom metric whose result depends on conditional rules rather than a single, fixed formula. Each rule follows a "when / then" logic:

  • When (condition): which campaigns the rule applies to. For example "when the source is Meta", or "when the campaign name contains Brand".

  • Then (outcome): which metric or formula to use in that case.

You can stack several rules within the same metric, each with its own condition — the platform automatically applies the right rule based on context (source, campaign...) at calculation time.

What's the benefit?

The same concept (clicks, conversions, engagement…) isn't always measured the same way across advertising sources. Each platform has its own definitions and available fields. Without rules, you'd either have to pick a single definition for all sources (which may not fit any of them well), or build a separate report per platform.

A rule-based metric solves this by letting you define a different rule per source (or condition) while keeping a single metric name across your reports and goals. Specifically, it's useful to:

  1. Harmonize a metric whose default definition doesn't fit a given source. On Spyne, the standard Clicks metric defaults to Meta's Link Click. If you'd rather track Meta's Click (All) (which also includes page clicks, reactions, etc.), a rule "when Source = Meta, then use the Clicks (All) conversion" lets you do that — without changing the definition of Clicks on your other sources (Google, TikTok…).

  2. Build a consistent metric out of different fields depending on the platform. For example, an "Engagement" metric that should use Likes on Meta but Clicks on Google: each source gets its own "then" rule, grouped under a single "Engagement" metric.

In every case, the benefit is the same: one single, readable, stable indicator over time, even if its technical definition varies behind the scenes depending on the source or campaign

How to access Rule-based metrics?

  1. Click your avatar at the bottom of the page, then select Workspace Settings

  2. From the navigation bar, select Metrics in the Workspace section.

How to create a rule-based metrics?

  1. Click Create metric at the top right of the page

2. Configure the custom spend details:

  • Name the custom spend, e.g. Client spend

  • Add a description to provide essential context for other users and for SpyneAI

  • Enter a prefix, e.g. $,€,£

  • Enter a suffix, e.g. %, kg

  • Decimal places. The number of decimal places to display by default is 2.

3. Select Rule-based metrics

Set up rules

  1. Click “+Add rues”

  2. Specify the channel or channels (Meta, Google, Tiktok, etc.) to which the rule should be applied. You can create different rules for each channel or use the same across multiple channels.

  3. Click on “+Add step”

  4. Set up the conditions the rules apply to.

    Each rule consists of the ‘when’ part specifies which campaign/ ad group/ ad the rule applies to, and the ‘then’ part specifies the expected results of the rule.

When

Define in which campaign name should the system look for information.

Then, set up the conditions.

Field value

  • Rules are applied to the field values. Several ways to identify the values that you want the system to extract.

    • Is in

      • It checks if the value matches any of the listed options.

    • Is not in

      • It checks if the value does not match any of the listed options.

    • Contains: Check if a part of the text is found within the value.

    • Does not contain: Check if a part of the text is not found within the value.

    • Exacts: Check if the value is exactly as what is specified.

    • Matches regex: Use advanced text extraction and value settings with a full regex integration

Multiple conditions

  • You can combine multiple conditions with the “+ Add condition” button. Conditions can be combined as AND (both conditions must be true).

No condition

  • If you want the “then” without any condition, you can remove the “when” by clicking on the grey cross on the right.

Then

This part is mandatory, it specifies what the action / result of the rule should be.

  • Type a metric name, as you start typing a list of available metrics will appear. Select the metric that you want to add to the formula from the list.

  • Use operators (+, -, *, /) and parentheses () by typing them directly from your keyboard, like regular text.

  • To remove a metric, operator, or parenthesis, simply delete it like normal text editing.

  • You can add constant, for example you would type *100 to multiply by a hundred for a percentage.

  • For more complex formulas you can include parenthesis "()".

Formula validation

  • An error message will appear if the formula contains invalid characters or unmatched parentheses.

  • A formula cannot start or end with an operator (+, -, *, /).

How to test rules and check the results?

You can check how the rules will apply to your custom metric over the last 30 days.

Click the button Test at the top right of the page. The test results will appear above the rules section.

Publish rule-based metric

Click on the 'Create custom metric' button at the top right of the page.

How to manage a rule-based metric ?

After the custom metric is published, it will appear in the table under the Custom Metrics section. To edit it, click the metric name in the table.

Or by selecting the ‘…’ menu in the header, you can edit, delete or duplicate the metric.

Update custom metric in case of changes

Click "Update metric" if you have made changes. Or, click on "Discard changes" if you do not want to save the changes.

Did this answer your question?