Notification

G Suite is now Google Workspace: everything your business needs to get work done.

Regex and CSS selector operators

You can use regular expressions (regex) and cascading style sheet (CSS) selectors as operators wherever trigger filters are used. When a regular expression or CSS selector is set as the operator for a trigger, you can specify that the trigger matches the rule.

Regex

The "matches regex" option allows you to implement regular expressions in Google Tag Manager for matching text patterns. Regex is useful for expressing more complex types of rules such as "fire the tag when the URL starts with A and ends in B or C."

For example, this regular expression when applied to a URL variable will match all pages with the string "pro" in the URL path, including "products", "promotions, "professionals", and "processes":

/pro/

CSS selectors

The CSS selector may be used to target specific HTML elements. For instance, this selector applied to a Click Element variable will match a click for any element with a class attribute value of "purchase" that is a descendant of an element with an ID attribute value of "promo":

#promo .purchase

Related resources

Was this helpful?

How can we improve it?
Search
Clear search
Close search
Google apps
Main menu
6881044196558518450
true
Search Help Center
true
true
true
true
true
102259
false
false