Difference between revisions of "CR.watchers"
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| + | {{deprecated|when=2025}} | ||
| + | |||
| + | See [[__CR.watch]] which is the function which replaces this member. | ||
| + | |||
| + | This member remains compatible, however, the value of `__CR.watchers` when read is not guaranteed to match versions prior to 2025. | ||
| + | |||
<code>__CR.watchers</code> is a member in the [[ConversionRuler JavaScript Global]], and is of type <code>array</code>. It represents a queue of functions to run, intermittently, to check for a condition which may exist on the page. The functions in this queue are run several times a second to monitor the [[DOM]] and the page for changes to the page which may represent [[Conversion Actions]]. | <code>__CR.watchers</code> is a member in the [[ConversionRuler JavaScript Global]], and is of type <code>array</code>. It represents a queue of functions to run, intermittently, to check for a condition which may exist on the page. The functions in this queue are run several times a second to monitor the [[DOM]] and the page for changes to the page which may represent [[Conversion Actions]]. | ||
| Line 29: | Line 35: | ||
[[Category:ConversionRuler]] | [[Category:ConversionRuler]] | ||
| − | [[Category:ConversionRuler | + | [[Category:ConversionRuler Deprecated]] |
Latest revision as of 16:50, 27 April 2026
See __CR.watch which is the function which replaces this member.
This member remains compatible, however, the value of `__CR.watchers` when read is not guaranteed to match versions prior to 2025.
__CR.watchers is a member in the ConversionRuler JavaScript Global, and is of type array. It represents a queue of functions to run, intermittently, to check for a condition which may exist on the page. The functions in this queue are run several times a second to monitor the DOM and the page for changes to the page which may represent Conversion Actions.
The passed in watcher function will be called several times a second until the function returns the exact value of false – any other value returned will leave the watcher function in the queue indefinitely, or until the function returns false.
Example usage:
<script>
__CR.watchers.push(function (cr) {
if (document.getElementById('message-sent')) {
cr.track("newsletter", null, cr.data("email"));
return false;
}
});
</script>
The signature of the function added to this queue is function (cr) { }, and
The first parameter is the ConversionRuler JavaScript Global (e.g. __CR) and the value for this in the passed-in function is typically set to the browser global object window.
This function should be used when a browser web application or web form modifies the DOM and you need to monitor the DOM for changes.
This functionality is only available as of September 12, 2018.