Dimensions
Learn how to update and add new custom dimensions to your report.
Custom Dimensions can be set up in a similar way to Calculate metrics using TiKiLa.
The most commonly used ways to create custom dimensions are splitting a name by a delimiter similar to the Text To Columns option in a spreadsheet or using IF / ELSE logic or using Regular Expressions to extract information identified by set of characters.
Example 1: Extracting the “video length” as a new custom dimension with IF ELSE
{{ if( stringContains( inputData("/ad_name"), "_16-30s_" ), "16-30s", if( stringContains( inputData("/ad_name"), "_11-15s_" ), "11-15s", if( stringContains( inputData("/ad_name"), "_7-10s_" ), "7-10s", if( stringContains( inputData("/ad_name"), "_4-6s_" ), "4-6s", if( stringContains( inputData("/ad_name"), "_1-3s_" ), "1-3s", "other" )))))) }}
Note that these are 6 IF() functions nested in one another. TiKiLa provides some validation to make sure you cannot save an incorrect formula
Example 2: Extracting the video length from the ad name
Assume your names all have the same structure, where, for video ads, you include the video length between the second and third _
, e.g. video_us-vs-them_16-30s_XMAS23_homepage
.
Using the splitString()
formula, we can break the name into its individual parts and the select()
the part that we want to use for our video length dimension:
{{ select( splitString(inputData("/ad_name"), "_") "/2" ) }}
splitString()
breaks up the ad name into it’s individual parts: ["video", "us-vs-them", "16-30s", "XMAS23", "homepage"]
We can use /2
as a pointer to the extract the item at index 2, which translates to the third item.
/0
→ first item
/1
→ second item
etc.
This now would set the video_length to 16-30s
for this ad.
Example 3: Extracting the main creative idea from an ad name
Assume your names do NOT have the same structure, but you use a character to define an element. E.g. your ad names might be “A1234_B06_C192_D101” and “A1235_D102_C193”
Using the stringExtractsRegex()
formula, we can find all matches of a specific pattern and then use the select()
formula to select the first occurrence:
{{ select( stringExtractsRegex(inputData("/ad_name"), "C[0-9]+") "/0" ) }}
stringExtractsRegex()
finds each occurence of a C followed by a set of numbers: So for the first ad this would return an array with one element ["C192"]
and for the second ["C193"]
. Selecting the element at index 0 would return C192
and C193
.
Last updated on March 25, 2024