Difference between revisions of "ConversionRuler JavaScript Global"

From Market Ruler Help
Jump to: navigation, search
(Created page with 'ConversionRuler, starting in 2016, stores most state and functional information within a single JavaScript global variable available in the global scope (or '''window''' scop…')
(No difference)

Revision as of 18:13, 30 June 2016

ConversionRuler, starting in 2016, stores most state and functional information within a single JavaScript global variable available in the global scope (or window scope):

    1. __CR

The JavaScript global __CR has the following fields and properties which are publicly accessible. Note the presence of the global in the window scope generally asserts that ConversionRuler tracking has been loaded and performed.

  • __CR.track - function - Track an action on this page
  • __CR.track_id - function - Track an element by ID on the page
  • __CR.link - function - Track links which direct to another page which may not have tracking ability
  • __CR.submit - function - Track forms which submit to another page which may not have tracking ability
  • __CR.query - function - Retrieve a value from the current page URL's query string
  • __CR.jquery - function - Load the jQuery library if it is not present in the global scope, and invoke the passed in function with the jQuery JavaScript global
  • __CR.cookie - function - Retrieve a value from the current site's cookies
  • __CR.site - string - Site ID most recently tracked by ConversionRuler
  • __CR.url - string - URL of the current page
  • __CR.frame - boolean - If the current page where ConversionRuler was loaded is an iframe or is within a HTML frame
  • __CR.user - string - Unique ID used by ConversionRuler to identify the current site visitor.

Access to any variables not named or listed above is not supported.

This global variable is passed as the first parameter to any function which is registered using the Tracking Queue. That is, the following snippets of code are equivalent:

<script>
window._crq = window._crq || [];
window._crq.push(function (cr) {
    cr.track('action');
});
</script>

is equivalent to:

<script>
window._crq = window._crq || [];
window._crq.push(function () {
    __CR.track('action');
});
</script>

See also