OpL Insights

Docs Any website

Configuration and API

Every configuration option and every function the script offers.

Configuration

Set window.OPL_INSIGHTS before the script loads.

Option Example What it does
m 'https://insights.opl-web.com/' The OpL Insights server. Required.
s 129 Your site ID. Required.
uid '[email protected]' The signed-in user, when the server knows it.
waitForUser 2000 Hold the first page view up to this many milliseconds (max 5000) until setUser or clearUser is called.
spa 1 Count in-app navigation as page views.
consent 'cookie_consent' Don't start until a cookie with this name exists. Checked every 2 seconds for 10 minutes.
rr 0 Turn off session recording for this page.
hm 0 Turn off heatmap collection for this page.
dt 0 Turn off console and network capture for this page.
debug true Print what the script does to the browser console.

Recording, masking, sampling and excluded pages are also set per site in OpL Insights (Websites > Manage), and those settings reach browsers within 10 minutes.

Functions

Available as window.OplInsights once the script has loaded.

Function What it does
OplInsights.setUser(id) Set the signed-in user.
OplInsights.clearUser() Clear it, after sign-out.
OplInsights.event(category, action, name, value) Record an event, e.g. OplInsights.event('Checkout', 'error', 'STALE_QUOTE').
OplInsights.version The script version.

The queue

Commands pushed to window._oplq before the script loads are run when it starts; after that, pushes run immediately.

(window._oplq = window._oplq || []).push(['setUser', '[email protected]']);
(window._oplq = window._oplq || []).push(['clearUser']);