Open navigation

How to use conditions with custom fields

A condition allows you to define data that you want to transform, and then apply a function or transformation to only that data.


The condition transformation is a versatile feature of our custom fields toolkit, enabling you to apply rules-based logic to manipulate data. With this capability, you can perform actions based on specific criteria within your data from platforms, such as Facebook Ads and Google Ads.


Use cases for condition transformations include:

  • Applying markup: Many advertising agencies add a standard markup to ad spend. To achieve this, you can use a condition like "IF Data Source equals 'Facebook', THEN Amount spent * 1.15 (for a 15% markup), ELSE Amount spent". This applies the markup only to Facebook ad spend.
  • Rounding large numbers: For better readability, round large impression numbers. For example, "IF Impressions greater than 1000, THEN round(Impressions/1000) & 'k', ELSE Impressions". This changes '1500' impressions to '1.5k'.
  • Flagging high budget use: Create a flag for campaigns nearing their budget. For instance, "IF Spend greater than 900, THEN 'Warning: Over 90% Budget', ELSE 'Within Budget'".
  • Transforming metrics based on dimensions: If you want to convert metric values for specific dimensions, use a condition like "IF Country equals 'US', THEN Revenue*1.15, ELSE Revenue". This converts revenue to USD for US-based data.

See this article for a full list of available functions.


Condition transformations allow you to tailor your data analysis to your specific needs. Conditions can also be combined with additional transformation steps in order to perform more complex sequences.


Instructions

  1. On the Supermetrics Hub, go to Transformations → Custom fields.
  2. Click Create new custom field.
  3. Select either dimension or metric and click Next.
    This selection is based on the aspect of the data you aim to manipulate.
  4. Select the data source you want to apply a transformation to, and click Next.
  5. Select Condition as your transformation type.
    This enables rule-based transformations of your data.
  6. Define your 'IF' condition. Select a field and an operator (equals, does not equal, contains, does not contain, matches regex, does not match regex, greater than, less than).
  7. Add 'AND' or 'OR' conditions for more sophisticated rules, involving multiple fields or values.
  8. Specify the 'THEN' action if your condition is met. You can select another field, define a static value, or even apply a function.
  9. For more versatility, define an 'ELSE IF' condition and corresponding 'THEN' action. These apply when the 'IF' condition isn't met but the 'ELSE IF' condition is.
  10. Finally, set an 'ELSE' action to handle all other cases when neither the 'IF' nor 'ELSE IF' conditions are met.
  11. Click Next.
  12. Give your custom field a name.
  13. Click Create custom field.

You can now use your new custom field in your reporting.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.