I want to track a variable which is populated by the IT team on a page. How do I keep a watch of that variable availability using DTM? which function need to be used?
Solved! Go to Solution.
First, create a Data Element of Type `JS Object`. For Path, specify the JS variable you want to "watch" for. Note that it must be a variable within the global (`window`) scope.
Next, Create an Event Based Rule. In the Conditions > Event section, select Event Type `dataelementchanged`, and select your Data Element from the dropdown.
At this point, the rule will now trigger whenever the value of your JS variable changes. If you want it to only trigger on certain values, then under Rule Conditions > Criteria, Select `Data : Data Element Value`, and click Add Criteria. Then select your data element from the Data Element dropdown, and specify your expected value in the Value field.
General note: `dataelementchanged` works by using `window.setTimeout` to poll the data element every ~100ms to compare the current value with the previous value. So there is site performance to consider with this type of event, especially if you plan on using it for many rules.
How/when is the variable populated? Is there a forum submission, page load, custom event, or other trigger that indicates the variable has been populated? Also, is this a simple javascript variable?
Views
Replies
Total Likes
First, create a Data Element of Type `JS Object`. For Path, specify the JS variable you want to "watch" for. Note that it must be a variable within the global (`window`) scope.
Next, Create an Event Based Rule. In the Conditions > Event section, select Event Type `dataelementchanged`, and select your Data Element from the dropdown.
At this point, the rule will now trigger whenever the value of your JS variable changes. If you want it to only trigger on certain values, then under Rule Conditions > Criteria, Select `Data : Data Element Value`, and click Add Criteria. Then select your data element from the Data Element dropdown, and specify your expected value in the Value field.
General note: `dataelementchanged` works by using `window.setTimeout` to poll the data element every ~100ms to compare the current value with the previous value. So there is site performance to consider with this type of event, especially if you plan on using it for many rules.
Did the above replies answer your question? If so, can you mark the answer correct?
Thanks,
Jantzen
Views
Replies
Total Likes
followup: not sure when (or more importantly, why..@adobe - change it back! or better, add a field in the EBR to specify! ) but FYI `dataelementchanged` now polls every 1000ms (1 second).
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies