Use Browser Console Commands

Overview

The Omniconvert tracking code adds a global object called _mktz to every page that loads it. From your browser's developer tools console you can use it to see which experiments are running on a page, find out why one is not, force a variation to appear, and listen for experiment events.

To use it, open the page you want to check, open the developer tools (in most browsers, press F12) and select the Console tab. Type or paste a command and press Enter.

Warning

Commands marked Sends data send real data to the tracking server, such as a view for the variation. Use them on test pages or with a test visitor. To make sure nothing is sent, add ?mktz_p= to the page address (see Preview URL parameters).

Inspect experiments

CommandWhat it does
_mktz.getLogs()Prints the debug trail. The event list shows why each experiment ran or was skipped.
_mktz.loggs.eventThe same event log, as the raw array.
_mktz.getExperiment()The experiments and variations applied on this page, or false if there are none.
_mktz.running_testThe same list as above, as the raw array.
_mktz._is_running(expId, varId)true if that experiment (and, optionally, that variation) is applied on this page.
_mktz._cachedRunnableExperimentIdsThe experiment ids that passed the pre-checks on this page load.
_mktz.experimentsAll experiments shipped to this website, keyed by id.
_mktz.experiments[123].variationsThe variations of one experiment, with their code, CSS and traffic allocation.
_mktz.getSeenVariations()The variations stored for goal attribution, as variationId=timestamp entries.
_mktz.getVisitor()The visitor data used by segments: device, browser, referrer, UTMs, visits and custom variables.

Find out why an experiment did not run

Pass an experiment object to each of these commands, for example var e = _mktz.experiments[123];. Each one returns true or false.

CommandWhat it checks
_mktz._check_where(e)Whether the current URL matches the include and exclude page rules.
_mktz._check_device(e)Whether the current device type is targeted (see _mktz.visitor.device_type).
_mktz._check_when(e)Whether the current day and time are inside the schedule.
_mktz._check_segment(e)Whether the visitor matches the experiment's segment.
_mktz._check_is_expired(e)true if the experiment is past its end date.

For a step-by-step checklist, see My experiment isn't running. What to check? and Debugging Experiments.

Apply experiments

CommandWhat it does
_mktz.applyExperiment('123-456')Sends data. Forces variation 456 of experiment 123 and skips targeting. For an A/B test it records a real view.
_mktz.applyExperiment(123)Sends data. The same, but it reuses the variation the visitor is already assigned to.
_mktz.push(['applyExperiment', '123-456'])Sends data. The same as applyExperiment, through the push API.
_mktz._deleteMktzCookies()Expires all mktz_* cookies. Reload the page to come back as a new visitor and be assigned to a variation again.

Single-page apps and re-initialization

These commands matter on single-page apps, where the page changes without a full reload. For setup, see Set Up Single-Page Application (SPA) Support.

CommandWhat it does
_mktz.init()Sends data. A full re-initialization: it resets the state, evaluates all experiments again and sends a view.
_mktz.initOnDemand()Sends data. A light re-initialization: it evaluates only personalizations and surveys again, and sends a view.
_mktz.events.trigger('pageview')Sends data. Simulates a virtual pageview. It runs initOnDemand.
_mktz.blockReinit()Stops init() from resetting the page. Split URL variations use this.
_mktz.unblockReinit()Allows resets again.
_mktz.isReinitBlockedWhether resets are currently blocked.

Listen to experiment events

Experiment events are CustomEvents dispatched on document. The details are in e.detail.

_mktz.events.on('omni:ab:inserted', function (e) { console.log(e.detail); });
EventFires when
omni:ab:insertedAn A/B variation was applied.
omni:interaction:insertedA personalization was shown.
omni:survey:insertedA survey was shown.
omni:experiments:finishedExperiment evaluation finished for this page.
omni:reinitTracking was re-initialized on a single-page app route change. The event carries from and to.
omni:error:genericAn exception was caught inside the tracking code, often in variation code.

Anti-flicker

CommandWhat it does
_mktz._flicker('isOn')true while the anti-flicker overlay is hiding the page.
_mktz._flicker('remove')Removes the anti-flicker overlay right away.

Preview URL parameters

These go on the end of a page address, not in the console. To get a preview link for an experiment, see Activate & Manage Experiments.

ParameterWhat it does
?mktz_p=123-456A live preview: it runs only variation 456 of experiment 123, and nothing is sent to the server.
?mktz_preview=1A proxy (editor) preview: tracking does not run.

Pages that use the SDK

On pages that use the Omniconvert SDK, the global object is _mktz_sdk.

CommandWhat it does
_mktz_sdk.enableDebug()Turns on detailed logging for the SDK's experiment applier.
_mktz_sdk.disableDebug()Turns it off again.
_mktz_clearPreview()Leaves SDK preview mode. It clears session storage and reloads the page.
Updated