Custom metrics and dimensions are created by entering JavaScript into the Nugit web app's custom metrics editor. You can use the custom metrics editor to create metrics and dimensions ranging from simple mathematical operations to advanced conditional statements like parsing values or if-else statements.
Step by step: How to create a simple custom metric derived from base metrics
Hover over a nugit and click on the Custom Metrics rectangular icon on the grey toolbar at the top of the nugit.
Enter a name for your custom metric. Each custom metric should have a unique name. You will not be able to create a custom metric that has the same name as any other metric.
Select a metric type and display format.
'Number', 'Money', 'Percentage', and 'Time' formats are for custom metrics
'String (Custom Dimension)' is for custom dimensions (i.e. text values)
Start formulating your custom metric:
Click on the metrics you want to include in your formula. They will automatically be added in-line into the text editor. You can also type their exact names in square brackets [ ].
Insert the operators you need to create your formula. You can use mathematical operators such as * (multiply), / (divide), + (add), and - (subtract).
Hit 'Create' to save your custom metric.
Types of Metrics
There are three types of metrics:
Maximisation metrics are values that indicate better performance when they increase (e.g. media spend or pages per session).
Efficiency metrics are values that indicate better performance when they decrease (e.g. media spend or cost per conversion).
For volume metrics, upward or downward changes are not automatically classified as positive or negative. (e.g. clicks or return on ad spend )
Display Format means the units and decimal places of your metric. If you are creating a custom dimension (text value), Display Format must be 'String (Custom Dimension)'.
Step by step: How to create a custom dimension by parsing data from an existing dimension
The .split function allows you to easily parse text or keywords from a specific position in an existing dimension and return it as a new value.
This comes in handy when you want to parse certain values from an existing dimension such as Campaign, that you would like to return as a new value under a new dimension (i.e. Targeting Info found in the Campaign taxonomy).
Open the custom metric editor and enter a name for your custom dimension.
Set the Display Format to 'String (Custom Dimension)' and enter the .split function in the editor.
An example of a .split function to lift the Search Category from your Campaign:
[Campaign].split("-")[3]
The Campaign value used in the example is AU-GO-G-Bags-Phrase
The above example returns the value 'Bags' based on the function of splitting the Campaign string using the delimiter '-' and returning the value found after the third delimiter.
You can use this example to split virtually any type of data in your existing dimensions that has a delimiter that can be used to identify the position of the value you wish to extract. It is important to note that since position is being used as an identifier in this function, the values that you wish to extract from a string should always be in the same position.
You can also consider adding ||"".trim() at the end of the code:
[Campaign].split("-")[3]||"".trim()
// where || is an OR operator and where "" signifies an empty string
// where .trim() is a method that removes whitespace from both ends of a string and returns a new string
The additional operators and functions help to:
return an empty string if the .split condition is not met (i.e. the Campaign string does not have a third delimiter in it, therefore there are no values that come after the third delimiter to parse)
remove any extra spaces in between the values that you are returning
Step by step: How to create a custom metric or dimension with conditionals
Open the custom metric editor and enter a name for your custom metric or custom dimension.
An example of an if-else condition that returns a metric:
if (/keyword_A/i.test([Dimension])){
return [Clicks]*2.3
}
else if (/keyword_B/i.test([Dimension])){
return [Clicks]*1.043
}
else {
return [Clicks]
}
The above example returns a multiplier of Clicks metric depending on whether Dimension contains keyword_A or keyword_B, and returns the original Clicks numbers if those two conditions are not met.
โ
Here's another example of an if-else condition that returns a dimension:
if ([Revenue] > 500) {
return "High"
}
else if ([Revenue] > 200 && [Revenue] <= 499) {
return "Average"
}
else if ([Revenue] <= 199) {
return "Low"
}
else {
return "NA"
}
The above example returns the following strings based on the Revenue amount.
"High" - Revenue is more than $500
"Average" - $200 < Revenue โค $499
"Low" - Revenue is less than $200.
You can combine multiple functions in the same code i.e. using if-else condition together with the .split function, to get the results that you need.
โ
Different formulas may be appropriate depending on your required outcomes. Feel free to reach out to your Customer Success Manager to discuss your use case.
Custom metrics and dimensions are stored per group. This means if you create a custom metric in Group A, it will not be available in Group B unless you copy it to Group B.
By default, the Media Spend metric type is set as neither an Efficiency or Maximisation metric, therefore the downward and upward changes will be displayed in blue, when making comparison over a selected time period.
If you would like to change Media Spend into a Maximisation or Efficiency metric, you would need to create a custom metric for Media Spend and set the metric type to:
Maximisation if you want the downward or upward changes to be displayed in red or green respectively; or
Efficiency if you want the downward or upward changes to be displayed vice versa