Difference between revisions of "CR.watchers"
(Created page with "<code>__CR.watchers</code> is a member in the ConversionRuler Global Object, and is of type <code>array</code>. It represents a queue of functions to run, intermittently,...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | <code>__CR.watchers</code> is a member in the [[ConversionRuler Global | + | <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]]. |
The passed in watcher function will be called several times a second until the function returns the exact value of <code>false</code> – any other value returned will leave the watcher function in the queue indefinitely, or until the function returns <code>false</code>. | The passed in watcher function will be called several times a second until the function returns the exact value of <code>false</code> – any other value returned will leave the watcher function in the queue indefinitely, or until the function returns <code>false</code>. | ||
Line 16: | Line 16: | ||
The signature of the function added to this queue is <code>function (cr) { }</code>, and | The signature of the function added to this queue is <code>function (cr) { }</code>, and | ||
− | The first parameter is the [[ConversionRuler Global | + | The first parameter is the [[ConversionRuler JavaScript Global]] (e.g. <code>__CR</code>) and the value for <code>this</code> in the passed-in function is typically set to the browser global object <code>window</code>. |
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 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 | + | This functionality is only available as of ''September 12, 2018''. |
== See also == | == See also == |
Latest revision as of 17:26, 30 January 2021
__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.