Can I set an eVar in one rule and use it in another rule?
Rule 1:
set eVar1 = something
Rule 2:
if (eVar1 = something) {
return true
} else {
return false
}
How do I do this?
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Or, are you talking about in Launch? Actually tagging the site based on values that have been set?
This is actually easy, but you wouldn't do it at the "eVar" level, but at the "Data Element" level...
Data Element "X"
set the value to something
Data Element "Y"
(Custom Code)
var myVariable = false;
if (_satellite.getVar('X') === "something"){
myVariable = true;
}
return myVariable;
I just shortened the code by setting the default value to false, so I didn't need all the "else" code.
Views
Replies
Total Likes
You can sort of do this.. but it's only available in calculated metrics....
So you can use an IF statement:
IF ]
[ Dimension X = something
metric (likely occurrences in this case)
]
[ Value If True
metric OR static value
]
[ Value If False
metric OR static value
]
]
So you can look for the dimension value and return "1" for true, and "0" for false (using Static Number)
But this may not be exactly what you need...
Views
Replies
Total Likes
Or, are you talking about in Launch? Actually tagging the site based on values that have been set?
This is actually easy, but you wouldn't do it at the "eVar" level, but at the "Data Element" level...
Data Element "X"
set the value to something
Data Element "Y"
(Custom Code)
var myVariable = false;
if (_satellite.getVar('X') === "something"){
myVariable = true;
}
return myVariable;
I just shortened the code by setting the default value to false, so I didn't need all the "else" code.
Views
Replies
Total Likes
Yes, you can set an eVar (variable) in one rule and then use it in another rule, but you need to ensure that the variable has been set before you try to use it in the second rule. Here's how you can do it:
Rule 1:
javascript
// Set eVar1 to something
s.eVar1 = "something";
In the above code, s is typically an object representing your analytics tracking instance,
and eVar1 is the variable you want to set.
Rule 2:
javascript
// Check if eVar1 has been set to "something"
if (s.eVar1 === "something") {
return true;
} else {
return false;
}
In Rule 2, you're checking if eVar1 has been set to "something". If it has, the rule returns true; otherwise, it returns false.
Make sure that these rules are executed in the correct order, with Rule 1 executing before Rule 2. This ensures that eVar1 has been set before you try to use it in Rule 2.
Views
Replies
Total Likes
Views
Likes
Replies