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.
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.
- On the Supermetrics Hub, go to Transformations → Custom fields.
- Click Create new custom field.
- Select either dimension or metric and click Next.
This selection is based on the aspect of the data you aim to manipulate.
- Select the data source you want to apply a transformation to, and click Next.
- Select Condition as your transformation type.
This enables rule-based transformations of your data.
- 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).
- Add 'AND' or 'OR' conditions for more sophisticated rules, involving multiple fields or values.
- Specify the 'THEN' action if your condition is met. You can select another field, define a static value, or even apply a function.
- 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.
- Finally, set an 'ELSE' action to handle all other cases when neither the 'IF' nor 'ELSE IF' conditions are met.
- Click Next.
- Give your custom field a name.
- Click Create custom field.
You can now use your new custom field in your reporting.