CR.instrument

From Market Ruler Help
Revision as of 17:15, 10 May 2020 by Admin (talk | contribs) (Created page with "<code>__CR.instrument</code> is a function available in the ConversionRuler JavaScript Global, and is of type <code>function</code>. The method signature for this is:...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

__CR.instrument is a function available in the ConversionRuler JavaScript Global, and is of type function.

The method signature for this is:

   __CR.instrument(specification, timeout);

Where:

  • specification - is an object which contains keys which map to jQuery Selectors for elements on the page and values which represent how data is to be stored in the CR.data structure
  • timeout - Is an integer specified in seconds, and if not specified defaults to 10 seconds. This represents the amount of time ConversionRuler will actively search for elements to instrument on the page.

Example usage:

<script>
__CR.instrument({
   "input[type=email]": "email",
   "input[autocomplete=email]": "email",
   "input[name*=company]": "company",
}, -1);
</script>

The instrumentation code operates as follows:

  1. The selectors you specified are "searched for" on the page, if they are found they are "connected" such that changes to the values in the inputs will be reflected immediately in the same value stored in __CR.data("...")
  2. The "connecting" process is what the timeout values refer to - this depends on whether you are instrumenting a site where the page changes (like a web application) then you would want to have this continuously running and instrumenting inputs as the page changes.

The type of target you specify using the jQuery Selector changes how the item value is saved:

- If your target is an :input then the value is updated whenever the control changes. - If it is <input type="hidden" ...> then the value is updated if the value changes. This allows support of 3rd-party widgets which manipulate hidden fields on a form, for example - For targets which are static page content such as text or static values, the values will reflect the most recent value of the jQuery text call for that selector and stored in the __CR.data("...")

A few other properties of this tools:

- Values stored in the data values are stored as strings, are always trimmed of whitespace, - The system will never store empty values - this avoids pages which load blank forms to not override existing values


This function is only available as of May 1, 2020.

See also