Skip to main content

How to Set Up Regex-Based Custom Dimensions in DatAds

Set up automatic custom dimensions in DatAds using regex to extract values from your naming convention like format, creator, or product directly from your ad names, without maintaining any lists.

Written by Kerim Ay

What the regex option does

When your ads follow a naming convention with a consistent separator, DatAds can read each position in the name and extract it as a dimension value automatically.

Think of your ad name as a train. Each car holds one piece of information, connected by a separator:

2026-08-14 | Video | Sophie | Always On | Vagisan | Hook A

A regex is an instruction to DatAds:

skip the first three cars and return the fourth. You define the rule once, and DatAds reads the value from every new ad automatically with no list to maintain.

Manual vs. Automatic at a glance

When to use

Manual

Small, fixed value lists, or ad names without a clean structure. You define each value manually via "Ad name contains X".

Automatic (Regex)

Clean naming convention with a consistent separator. Best for fields with many or frequently changing values (hooks, testing variables, and similar).

Step 1: Map your naming convention

Write out your convention and number each field from left, starting at 1. Example:

Date | Format | Creator | Always On/Testing | Product | Testing Variable  
1 2 3 4 5 6

Note which separator you use. In the example above it is the pipe |. Other common separators are ., -, and _.

Important: The separator must not appear inside any field value. If your convention uses - but a script name like silence-after-airdrop contains hyphens, every position after it shifts by one without any warning. Choose a separator that never appears in your values.

Step 2: Build the regex

The formula for "return the field at position N":

^(?:[^T]*T){N-1}([^T]*)T
  • T = your separator character

  • N-1 = number of fields to skip (position minus 1)

  • Whatever is inside ( ) is the value DatAds extracts

Example: separator |, field at position 4 (Always On/Testing)

^(?:[^|]*\|){3}([^|]*)\|

Starting from the beginning of the name (^), skip three occurrences of "anything plus pipe" ({3}), then capture everything up to the next pipe as the value (([^|]*)).

Copy & paste for the example above:

Date (position 1)               ^([^|]*)\| 
Format (position 2) ^(?:[^|]*\|){1}([^|]*)\|
Creator (position 3) ^(?:[^|]*\|){2}([^|]*)\|
Always On/Testing (position 4) ^(?:[^|]*\|){3}([^|]*)\|
Product (position 5) ^(?:[^|]*\|){4}([^|]*)\|
Testing Variable (position 6) ^(?:[^|]*\|){5}([^|]*)$

To add another field, change only the number inside the curly braces { }.

Special case, last field:

There is no separator after the final field. Use ([^T]*)$ rather than (.*)$. If an ad name has an unexpected extra segment after the last field (a typo, an appended suffix), ([^T]*)$ returns no value so you notice the issue immediately. (.*)$ silently includes the remainder in the extracted value.

Other separators

Examples using position 4:

Dot          ^(?:[^.]*\.){3}([^.]*)\. 
Hyphen ^(?:[^-]*-){3}([^-]*)-
Underscore ^(?:[^_]*_){3}([^_]*)_
Pipe ^(?:[^|]*\|){3}([^|]*)\|

Dot and pipe are regex special characters and need a backslash outside square brackets (\. and \|). Hyphen and underscore do not. Inside square brackets ([^.]) no escaping is needed.

Whitespace around the separator

If your ad names look like Video | Sophie, the extracted value includes a leading space. To trim it:

^(?:[^|]*\|){2} *([^|]*?) *\|

Step 3: Create the dimension in DatAds

  1. Open Create Dimension.

  2. Name: What the field should be called in reports and filters, for example Format.

  3. Description: A short note on where the value comes from, for example "Field 2 of the naming convention (Video, Static, Carousel)". This helps everyone in the workspace understand what the dimension represents.

  4. How to define values: Select Automatic.

  5. Value extractor (regex): Paste your regex.

  6. Only index new ads created from today: Leave this off if you want to analyze historical ads. Enable it only if your naming convention is new and old ad names do not follow the pattern.

  7. Click Create. Then verify the extracted value on several different ads, not just the one you used for testing. Ads from other campaign types or without complete tagging often break the pattern, and a real sample shows you where the structure fails.

Troubleshooting

Symptom

Cause

Fix

No value on some ads

Ad name has fewer fields, a different separator, or does not follow the convention (catalog ads, different campaign type)

Fix the naming convention in Meta or TikTok, or use Manual for legacy ads and non-standard types

Value has leading or trailing spaces

Spaces around the separator

Use the whitespace variant (see above)

Value is far too long

Separator appears inside a field value

Choose a different separator or update the field values

All positions are off by one

N-1 and N confused

Check the number in { }: position 4 means {3}

Regex is rejected

Constructs like (?=...) or (?<=...)

DatAds uses RE2. Lookahead and lookbehind are not supported

Every ad returns the same value

Capture group ( ) is missing or wraps the wrong part

The capture group must surround only the value you want to extract

Last field contains unexpected extra text

An undocumented segment (ID, date, status) appears after the last field

Use ([^T]*)$ instead of (.*)$ so extraction fails visibly rather than silently pulling in extra content

Tip: Let AI write the regex for you

You do not need to learn regex from scratch. Copy this prompt into ChatGPT or Claude and fill in the highlighted parts:

I need a regex for the tool DatAds. DatAds extracts values from ad names using RE2 syntax. Requirements:  - The regex must be RE2-compatible (no lookahead, no lookbehind). - The value to extract must be in exactly one capture group in round brackets. - The regex must be anchored at the start of the ad name.  My naming convention is: >>> Date | Format | Creator | Always On/Testing | Product | Testing Variable <  Here are several real ad names from my account (not just one): >>> 2026-08-14 | Video | Sophie | Always On | Vagisan | Hook A >>> 2026-08-12 | Static | Nadja | Testing | Emma Sleep | Hook C >>> 2026-07-30 | Carousel | Sophie | Always On | Vagisan | Hook B <  Give me a table with one regex per field. Explain in one sentence what each regex does, and flag any field that cannot be extracted cleanly or where the examples are inconsistent.

Two things that make a real difference:

  1. Provide multiple real ad names, not just the schema. The AI spots spaces, special characters, and inconsistencies, and will tell you if your convention is not being followed consistently across your account.

  2. Test before saving. Paste the regex into regex101.com, select Golang as the flavor (this matches RE2), add several ad names to the test field, and confirm the capture group highlights the correct value for each one.

Related articles

If you have any questions or would like to share feedback, feel free to reach out to us anytime via the chat widget in the bottom right corner of your dashboard. 💬

Did this answer your question?