The Custom measures tool is what we can use to give more numeric details to data on Analytics reports.
They can be used for simple counts of data, for example:
- The number of multi-store locations in a grouping
- The number of customer names associated with a particular email address
- The number of discounts used in a particular time frame
They can also be used for more complex counting, for example:
- The number of sales where the sales line employee is not the sale employee
- The number of instances where an ID field (like vendor ID, UPC, or manufacturer SKU) is empty
- The number of times when a certain tag occurs in products
Finding custom measure option
The Custom measure option lives in the Custom fields section, to the left of your Analytics data:
To create a new custom measure, follow Custom fields> Add> Custom measure.
A simple custom measure
The most basic usage of custom measures is count distinct, where the number 1 is assigned to each instance of a dimension being measured.
Say you want to count the number of stores that processed sales each day. When you open the custom measure editor, you see this panel:
If you click on the Field to measure > Choose field menu, you'll see a list of available dimensions that you can scroll through:
Or, you can start typing the name of the field you're looking for and you'll get options that meet your criteria:
Once you select your dimension to measure, you can either select Count distinct, which assigns a 1 to each unique dimension:
Or, select List, which presents the results as a list of all results:
Like custom dimensions, you need to run your report a second time to pull the results onto the table:
And, like custom dimensions, you should assign a meaningful title to the custom measure:
A more complicated custom measure
Say you want to find the number of times when the sales line employee was not the same person as the sale employee. You can use a custom measure to count this.
From the custom measure editor, select the Custom filter checkbox:
Then you'll see the code editor, which uses Look ML — the same language used in calculations and custom dimensions.
Here is how to build a simple logical calculation:
In this instance, search for instances of whether the employee equals the sale line employee, and count the numbers where the answer is No.
When I save the results, the results seem really low. Why? Because in this example, it was asked to count employees that were not the same as sale line employees.
What to properly ask is to count sales where the employee was not the same as the sale line employee.
So, go back to the editor by selecting the gear icon and Edit.
My code stays the same, but instead, I'm changing the Field to measure from Employee:
...to Sale ID:
Now, save and run:
Quick builder
Finally, you can jump-start custom measures from dimensions themselves.
When you hover over any dimension to the left-hand side of our data, you’ll see three little dots:
When you click on the dots, you get the option to aggregate:
Selecting Count distinct or List of unique values launches either of these custom measures into your data.