Custom dimension rules consist of two main parts, the 'when' part, which specifies which rows the rule applies to, and the ‘then’ part of the rule, which specifies what the result of the rule should be. In the rules below the 'then' is bold:
If data source type is Facebook then traffic source is set to “facebook”.
If campaign is not empty then Tactic is the value of campaign.
Funnel gives you a range of tools for managing the 'then' part of your rule, and thereby deciding what the result of the rule should be.
Setting a rule result
There are three ways to get the initial rule result:
Enter a text value yourself
Get the value of a dimension
Get the result of the regular expression used in your rule.
The rule below will return traffic source “X Ads” for all X Ads data.
Value of a dimension
The rules below combine data from dimension ‘Campaign’ from a file upload with data from dimension ‘Ad Group Name’ from Bing into a new dimension called My Campaign:
source 'Other (File Upload)', Campaign 'shirts' = 'shirts'
source 'Other (File Upload', Campaign 'hats' = 'hats'
source 'Bing', Ad Group Name 'hats' = 'hats'
You can divide text around a specified character or string. To do this, use ‘split by’ to provide a delimiter. Then you can use ‘split results’ and choose which ‘fragment’ to have as the result. Leading or trailing whitespace will be removed.
Will result in:
“Spring | Search | Shirts | Short sleeve” => “Shirts”
“Spring | Display | Hats | Brimmed” => “Hats”
(For more details, see How to use Text Splitting)
You can use a regular expression to find matching rows in your data. You can also use the same regular expression to set the value, in other words, extract the matching part of the data and use it as the result. This works if your regular expression has a capture group, for instance, the rule below:
Will result in:
Campaign 'td_se_shirts' = 'shirts'
Campaign 'fb_se_hats' = 'hats'
More examples here
Manipulating the rule results
Once you have your initial dimension rule result you can manipulate it in a number of ways:
Append another value to it,
Truncate the value,
Replace characters in it,
Convert the value in various ways (see below).
You can chain these functions together, for instance you can:
Set to “td_se_” → append value of “Ad set” → convert to lowercase → append “_display”
Add a new value to the end of the current value. The new value can be text you enter yourself, the value of another dimension, or the result of a regular expression in your rule.
You can use this to, for example, concatenate two dimensions, like this:
This would result in:
source 'display', medium 'cpc' = 'display_cpc'
source 'google', medium 'organic' = 'google_organic'
Shortens the value to the first X characters, so for instance truncating ‘Apples and pears’ to first 10 chars becomes ‘Apples and’.
Converts the entire value using one of the methods below.
To Lowercase - Converts the entire value to lower case, e.g. ‘Apples And Pears’ becomes ‘apples and pears’.
To uppercase - Converts the entire value to upper case, e.g. ‘apples And pears’ becomes ‘APPLES AND PEARS’
Capitalize - Converts the first letter of the value to upper case and the rest to lower case, e.g. ‘apples And Pears’ becomes ‘Apples and pears’.
Trim whitespace - Removes spaces, tabs and other whitespace from the beginning and end of the value, e.g. ‘ apples and pears ‘ becomes ‘apples and pears’.
Unescape - Unescape escaped HTML characters, e.g. ‘apples & pears’ becomes ‘apples & pears’.
To country code - Convert known country codes and names to matching 2-letter country code ISO_3166-1, e.g. 'us', 'US', ‘USA’ and `The United States of America' becomes ‘US’.
To country name - Convert known country codes and names to commonly used name. , e.g. 'us', ‘USA’ and `The United States of America' becomes ‘United States’.
For date fields (matching YYYY-MM-DD format) you can use on of these:
to day of week (e.g. "Friday")
to week number (e.g. "05")
to ISO week number (e.g. "53")
to week start-end (e.g. "Jan 30–Feb 5")
to month name (e.g. "February")
to month number (e.g. "02")
to year (e.g. "2022")
to start of month (e.g. '2022-01-01')
to end of month (e.g. '2022-01-31')
to start of week (e.g. '2022-01-30')
to end of week (e.g. '2022-02-05')
to year week number (e.g. '202153')
Replace characters in the value with other values. For example replacing ‘+’ with ‘ ’ will turn ‘hats+UK’ into ‘hats UK’.
Like ‘replace’ but uses a regular expression to match the characters to be replaced, for instance replacing /^(SWE|sv|SV)/ with ‘se’:
value 'SWE_marketing_shirts' = 'se_marketing_shirts'
value 'sv_hats' = 'se_hats'
value 'us_black-friday_shoes' = 'us_black-friday_shoes'