Skip to content

Add support for EQUALS macro to allow for easy variable substitution #22160

@harshvcs

Description

@harshvcs

Add EQUALS macro to allow for easier string output mapping

There is currently no support from available macros to map variable values that might be required by a vendor in their amp-analytics vendor file. To achieve multiple output string mapping, most of the vendors will need something that checks for equality - say a new EQUALS macro (that returns a===b) along with the existing $IF macro.

Assuming $EQUALS is added, then a required mapping like "A" -> 1, "B" -> 2, "C" -> 3 can be solved using:

$IF($EQUALS(${variable}, A), 1, $IF($EQUALS(${variable}, B), 2, 3));

Alternative

An alternative that uses the $REPLACE macro is shared here, but in general, it is cumbersome to implement and understand.

Additional context

This is originally discussed with @zhouyx in #18034

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions