Go Back

Conditions

August 9, 2018

A condition is an additional mode of the trigger. It enriches it and makes it more accurate according to the specific case you are overlooking.

In every Trigger, you can choose an option of Firing tag on all pages or Firing tag when conditions are met. The second one gives us a whole range of additional options we can base our trigger on.

General Conditions:

Condition Description
contains condition is met when given string is a sub string of variable’s value; this comparison is made after both operands are converted to string
doesn’t contain condition is met when given string is not a sub string of variable’s value; this comparison is made after both operands are converted to string
starts with condition is met when variable’s value starts with given string; this comparison is made after both operands are converted to string
doesn’t start with condition is met when variable’s value doesn’t start with given string; this comparison is made after both operands are converted to string
ends with condition is met when variable’s value end with given string; this comparison is made after both operands are converted to string
doesn’t end with condition is met when variable’s value doesn’t end with given string; this comparison is made after both operands are converted to string
equals condition is met when variable’s value is equal to given string; this comparison is made after both operands are converted to string
doesn’t equal condition is met when variable’s value is not equal to given string; this comparison is made after both operands are converted to string
regexp condition is met when variable’s value matches given regular expression; pattern matching is made after both operands are converted to string;

Examples:

[cC]at – will match either cat or Cat
2\d{3} – will match a number between 2000 and 2999

regexp doesn’t equal condition is met when variable’s value doesn’t match given regular expression; pattern matching is made after both operands are converted to string;
is true condition is met when variable’s value is boolean true; no type conversion is performed; that means you cannot use Constant variable type with value TRUE/true because that will be understood as string
is false condition is met when variable’s value is boolean false; no type conversion is performed; that means you cannot use Constant variable type with value TRUE/true because that will be understood as string
is set condition is met when variable is defined, that means when it is not null nor undefined
is not set condition is met when variable is not defined, that means when it is null or undefined
is empty condition is met when variable’s value is one of:

  • 0 (a number zero, string zero will not met this condition),
  • ” (an empty string),
  • undefined,
  • null,
  • false (boolean value),
  • [] (an empty array – one can be passed via dataLayer or can be created with Custom JavaScript variable),
  • {} (an empty object – one can be passed via dataLayer or can be created with Custom JavaScript variable).
  • is not empty condition is met when variable’s value is not one of:

  • 0 (a number zero, string zero will not met this condition),
  • ” (an empty string),
  • undefined,
  • null,
  • false (boolean value),
  • [] (an empty array – one can be passed via dataLayer or can be created with Custom JavaScript variable),
  • {} (an empty object – one can be passed via dataLayer or can be created with Custom JavaScript variable),
  • Traffic source specific Conditions

    Condition Description
    is same as equals
    is not same as doesn’t equal

    Returning visitor specific Conditions

    Condition Description
    yes condition is met when visitor was on the page already
    1st visit condition is met when user is visiting site for the first time

    Click element specific Conditions

    Condition Description
    matches condition is met when clicked element matches given CSS Selector or XPath selector
    doesn’t match condition is met when clicked element doesn’t match given CSS Selector or XPath selector
    is a child of condition is met when clicked element is a child of element matched by given CSS Selector or XPath selector; parent is checked recursively up to 100 elements in the html tag tree
    isn’t a child of condition is met when clicked element is not a child of element matched by given CSS Selector or XPath selector; parent is checked recursively up to 100 elements in the html tag tree