DTM Property or Variable Watcher

Avatar

Avatar

chouhandt

Avatar

chouhandt

chouhandt

17-10-2017

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?

Accepted Solutions (0)

Answers (4)

Answers (4)

Avatar

Avatar

joshd7227840

MVP

Avatar

joshd7227840

MVP

joshd7227840
MVP

19-10-2017

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.

Avatar

Avatar

joshd7227840

MVP

Avatar

joshd7227840

MVP

joshd7227840
MVP

17-11-2017

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). 

Avatar

Avatar

jantzen_belliston-Adobe

Community Manager

Total Posts

1.9K

Likes

312

Correct Answer

570

Avatar

jantzen_belliston-Adobe

Community Manager

Total Posts

1.9K

Likes

312

Correct Answer

570
jantzen_belliston-Adobe
Community Manager

17-11-2017

A Chouhan

Did the above replies answer your question? If so, can you mark the answer correct?

Thanks,

Jantzen

Avatar

Avatar

jantzen_belliston-Adobe

Community Manager

Total Posts

1.9K

Likes

312

Correct Answer

570

Avatar

jantzen_belliston-Adobe

Community Manager

Total Posts

1.9K

Likes

312

Correct Answer

570
jantzen_belliston-Adobe
Community Manager

18-10-2017

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?