A flexible macro template for Boolean comparisons within Google Tag Manager, enabling conditional checks between variables.
GTM Community Template Gallery
The template accepts three input parameters:
Input Variable: Variable to be evaluatedCondition: Type of comparison to executeUser Input: Value to compare against the variable
- Equals
- Does not equal
- Contains
- Does not contain
- Starts with
- Does not start with
-
Input Acquisition
const inputA = data.inputVar; const inputB = data.inputUsr; const condition = data.condition;
-
Conditional Evaluation Specific checks are performed based on the selected condition:
- Direct equality comparison
- Substring search
- String start verification
- URL filtering
- Input validation
- Conditional checks in tags and triggers
// Check if a URL contains a specific domain
const data = {
inputVar: 'https://www.google.com',
inputUsr: 'google',
condition: 'contains'
};
// Returns: true- Supports string comparisons only
- Case-sensitive
- Always returns a Boolean value