CR.watch

From Market Ruler Help
Revision as of 16:31, 27 April 2026 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

__CR.watch is a function in the ConversionRuler JavaScript Global with the following arguments:

  • watchFunction of type function

watchFunction is a function which takes the ConversionRuler JavaScript Global as its first argument. The return value of this function, when false and only when false - terminates the watcher function permanently.

A watcher function is run, intermittently, to check for a condition which may exist on the page. This function is run several times a second to monitor the DOM and the page for changes to the page which may represent Conversion Actions. When implementing a watcher function, make the amount of time spent by your function as small as possible.

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>
(function (w, q) {
  (w[q] = w[q] || []).push(function (cr) {
    cr.watch(function (cr) {
      if (document.getElementById('message-sent')) {
        cr.track("newsletter", null, cr.data("email"));
        return false;
      }
    });
  });
}(window, '_crq'));
</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 December 31, 2025.

See also