Analytics · JavaScript Reference

Onesecondbefore's Analytics JavaScript library lets you collect information about visitors on your website. It consists of a set of commands (e.g. send or set) and a set of (configuration) options that set certain values or change the library's behaviour.

Commands

Onesecondbefore's Analytics Javascript library is used with the following snippet:

osb(command, ...options)

Where command is a constant string that tells the command queue what it should do and options supply additional information to that command. The following commands are supported:

They are described in more detail below.

osb('set', ...) and osb('add', ...)

Sets or adds additional properties in the payload. The payload will not be sent after a 'set' or 'add'command. Only a subsequent 'send' will send the hit. Use 'add' if you want to add the { data ... } to any pre-existing data rather than overwriting the value.

Usage

osb('set', name, { data... }); // Sets an object e.g. page
osb('add', name, { data... }); // Adds an object to an array e.g. ids
osb('set', name, [{ data... }, ...]); // Sets an array of objects, e.g. items

Parameters

nametyperequireddescription
'set' or 'add'stringyesName of command. 'set' to overwrite any existing value; 'add' to append to an already existing value.
namestringyesWhich record of the payload would you like to update, supported values are 'action', 'consent', 'event', 'ids', 'items', 'page'.
{data... }JS object or JS arrayyesChoose the correct option depending on the value you chose for name:

Common use-cases

Adds the Google Analytics client id to the payload (that will be sent with the next 'sent' command)

osb('add', 'ids', {
    key: '_ga',
    value: 'cookie:_ga' // 'GA1.2.123456789.1612345678'
});

Add a product item and add two custom product variables: color and size.

osb('add', 'items', { 
    id: 'abc123',
    category: 'clothing/dresses',
    name: 'BlackButterfly',
    color: 'green',
    size: 'm'
});

Set multiple products in a single command.

osb('set', 'items', [{
    id: 'sku123',
    name: 'Apple iPhone 14 Pro',
    category: 'mobile',
    price: 1234.56,
    quantity: 1
}, {
    id: 'sku234',
    name: 'Samsung Galaxy S22',
    category: 'mobile',
    price: 1034.56,
    quantity: 1
}]);

Set and hash an email address. Hashing happens in-memory on the Analytics server.

osb('set', 'ids', [{
    key: 'email',
    value: 'john.doe@example.com',
    hash: true
}]);

If the page has a <meta> tag like this:

<meta name="article-id" content="12345"/>

Retrieve this information with:

osb('set', 'page', {
    'id': 'meta:article-id' // '12345'
});

Retrieve information from an external URL and parse the JSON response to retrieve its value.

osb('set', 'page', {
    /* This URL should return a JSON response with a key 'user_id' */
    'user_id': 'url:https://api.example.com/getid'
});

Set consent information

//All purposes
osb('set', 'consent', 'all');

//Multiple purposes
osb('set', 'consent', 'necessary,analytics');

//Send the TC string (IAB Europe)
osb('set', 'consent', 'CPUP3OWPUP3OWFjAOBENChCsAP_-AH_-ABpaxK...');
[top]

osb('config', ...)

Allows reconfiguration of an existing tracker. This is e.g. required if before cookie consent you're not allowed to store the entire IP address ({ ipSettings: 1 }), whereas after you're allowed to do so ({ ipSettings: 0 }).

Usage

osb('config', { options... });

Parameters

nametyperequireddescription
'config'stringyesName of command.
{options...}JS objectyesChoose from configuration options

Common use-cases

Change the siteId for the tracker. It is recommended to label all activity from the same app or website with the same siteId.

osb('config', {
    siteId: 'my.web'
});

Change the IP address and cookie settings default behaviour.

osb('config', {
    ipSettings: 3
    cookieSettings: 2
});
[top]

Below documentation describes the consent possibilities in the regular tracker library loaded as osb.min.mjs. For the CMP version, look here.

Verify whether user has given cookie consent. There are two different implementations possible:

Using an external / central cookie domain

If the user has given consent, continue on the same page, otherwise, redirect the browser to a specified cookie consent page where the user can give their consent. If consent has already been given (if there are multiple sites under the same consent page), or the user has given consent, the user is redirected back to the current page with an additional querystring parameter which indicates that the user has given consent or not. If the user gave consent, a first-party cookie will be set.

Contact us to setup the cookie consent template, domain name, DNS and SSL certificate(s).

See here for more information.

Using a cookie bar on every page

If you would like to show a (simple / sticky) cookie bar on every page with buttons to either allow or deny consent. A cookie bar is made visible if no consent has been given on the current website. Two buttons can be added to the cookie bar to allow / deny consent. If (no) consent is given, a first-party cookie will be set and the cookie bar will be hidden. Additionally, a third button can be added with a number of checkboxes to specify which purposes have been consented. These purposes have no relation with the TCF version.

See here for more information.

Load the osb.min.mjs version of the tracker library.

Parameters

parameter nametyperequireddescription
'consent'stringyesName of command.
{ consent options }JS objectyesOptions to configure the consent page, see below.

Consent options for external cookie domain

consent optiontyperequireddescription
callbackJS functionnoCallback function(consent, cduid) called after the redirect to the original page where consent was requested. This callback is fired both for consent accepted and not accepted. The consent parameter either contains the string "all" or "none" (when the buttons to allow or deny all consents were clicked), or it contains a string with comma separated purposes that were checked (when the button to save preferences was clicked). Additionally, the cduid parameter contains the cross-domain user-id as analyticsd on the consentUrl domain name.
cduidNamestringnoName of querystring parameter and first-party cookie name for cross-domain user-id added to the URL of the original page where consent was requested, default 'cduid' for the query string parameter and '_osb_cduid' for the cookie name.
consentNamestringnoName of querystring parameter and first-party cookie name that stores which consent the user has given consent, default 'consent' for the query string parameter and '_osb_consent' for the cookie name.
consentUrlstringyesURL to redirect browser to page where user gives consent, e.g. 'https://privacy.example.com'.

Example

If consent needs to be given by the visitor they might see a flash of content of the current page if it takes some time to execute all the javascript and redirect the user to the consent page. To eliminate this, the following can be used:

  • Add an osb-cloak attribute to the body of the HTML document:
    <body osb-cloak>
  • Add the following CSS style:
    [osb-cloak] > * { display: none; }
    /* Optional */
    [osb-cloak]::before { content: "Please wait..."; }
  • If consent has (already) been given (or not) the osb-cloak attribute will be removed automatically from the <body> by osb('consent', ...) and hence the page is visible.

Use this version if your website implements a cookie bar or similar on every page, as demonstrated in the videos below.

The cookie bar has the following requirements:

  • The cookie bar has an HTML id as specified by the consentId, e.g. 'cookiebar'.
  • The cookie bar has at least the following CSS (by default it is hidden, if class show is added, the cookie bar becomes visible).
    #cookiebar { display: none; }
    #cookiebar.show { display: block; }
  • The cookie bar contains an <a class="allow"> or <button class="allow"> element the user can click to allow consent.
  • Optionally, the cookie bar also contains a <a class="deny"> or <button class="deny"> the user can click to deny all consent.
  • Optionally, the cookie bar also contains a <a class="save"> or <button class="save"> the user can click to save all consents that were selected using <input type="checkbox" name="purpose">.

When the above conditions are met, the script will verify whether consent has been given, if not the cookie bar will be shown and event listeners will be added to the allow and optionally to the deny and save buttons. When a button is clicked a first-party cookie is set with the given consent, the cookie bar is hidden again and the optional callback function is executed.

Consent options for cookie bar

consent optiontyperequireddescription
consentIdstringyesHTML id of the cookie bar HTML element, e.g. 'cookiebar'.
callbackJS functionnoCallback function(consent, cduid) called after the redirect to the original page where consent was requested. This callback is fired both for consent accepted and not accepted. The consent parameter either contains the string "all" or "none" (when the buttons to allow or deny all consents were clicked), or it contains an string with comma separated values of the purposes that were checked (when the button to save preferences was clicked).
consentNamestringnoName of first-party cookie used to store consent, default '_osb_consent'.

As an example, use the following HTML on every page:

<style>
#cookiebar {
  display: none;
  color: #fff;
  background-color: #000;
  padding: 15px;
  position: fixed;
  bottom: 0;
  width: 100%;
  z-index: 20;
}
#cookiebar.show {
  display: block;
}
</style>
<div id="cookiebar">
    <p>
        Lorem ipsum dolor sit amet
        <a href="/link/to/privacy">privacy statement</a>.
    </p>
    <button class="btn btn-primary allow">OK, give consent</button>
</div>

And the following javascript:

osb('consent', { consentId: 'cookiebar' } );

The cookie bar is then shown if no consent is given.

Below example shows allow, deny and save buttons and various purposes which will be saved. The values and labels for these purposes are arbitrary, but obvious choices are "necessary" or "functional", "analytics", "marketing" or "advertising", and "social". Note that the <input type="checkbox"> should have name="purpose". It would render as in below screenshot:

Screenshot Cookie Bar advanced example

<style>
/* Same as example above */
</style>
<div id="cookiebar">
    <p>
        Lorem ipsum dolor sit amet.
        <a href="/link/to/privacy">Privacy policy</a>.
    </p>
    <p>
        <label><input type="checkbox" name="purpose" value="necessary">Necessary</label>
        <label><input type="checkbox" name="purpose" value="analytics">Analytics</label>
        <label><input type="checkbox" name="purpose" value="marketing">Marketing</label>
        <label><input type="checkbox" name="purpose" value="social">Social Media</label>
    </p>
    <p>
        <button class="btn btn-secondary save">Save preferences</button>
        <button class="btn btn-secondary deny">Deny all</button>
        <button class="btn btn-primary allow">Allow all</button>
    </p>
</div>

And the following javascript:

osb('consent', {
    consentId: 'cookiebar',
    callback: function(consent, cduid) {
        if (consent === 'none') {
            alert('No consent given');
        } else if (consent === 'all') {
            alert('All consent given');
        } else if (consent?.includes('marketing')) {
            alert('Marketing consented');
            // ... etc.
        }
    }
});
[top]

Below documentation describes the consent possibilities in the IAB TCF v2.0 tracker library loaded as osb-cmp.min.mjs. For the regular version, look here.

Verify whether user has given cookie consent using the IAB TCF v2.0 standard.

Usage

Load the osb-cmp.min.mjs version of the tracker library to include IAB TCF 2.0 compatibility.

Parameters

parameter nametyperequireddescription
'consent'stringyesName of command.
{ consent options }JS objectyesOptions to configure the consent page, see below.

Consent options for external cookie domain

consent optiontyperequireddescription
callbackJS functionnoCallback function(consent, cduid) called after the redirect to the original page where consent was requested. This callback is fired both for consent accepted and not accepted. consent is a JavaScript object with the following fields:
tcstring
The encoded IAB TCString
purposes
JS array with consented IAB purpose identifiers (integers 1-10)
legitimateInterests
JS array with consented IAB legitimate interest identifiers (integers 1-10)
specialFeatures
JS array with consented IAB special feature identifiers (integers 1-2)
vendorConsents
JS array with consented IAB vendors identifiers (integer)
vendorLegitimateInterests
JS array with consented legitimate interests for IAB vendor identifiers (integer)
configUrlstringyesURL to retrieve CMP configuration from. Contact us for guidance.
showboolean or number or function returning a boolean or number.noIf null (default), show the CMP if consent not yet given, don't show when consent already given.
If true, show CMP, regardless of whether consent has been given or not.
If false, do not show CMP, regardless of whether consent has been given or not.
If 1 surface the homepage of the CMP.
if 2 surface the purposes and legitimate interests list.
if 3 surface the vendor list.

Examples

If visitor consented to purpose 1, update the ipSettings configuration parameter.

Add a LinkedIn pixel if purposes 1, 8 and 15 have been consented.

Open CMP at a particular "page" or "tab":

[top]

osb('debug', ...)

Enables / disables additional debug logging in the console.

Usage

// Additional debugging information will be displayed in the JavaScript developer console.
osb('debug', enabled);

Parameters

parameter nametyperequireddescription
'debug'stringyesName of command.
enabledbooleanyestrue to enable more debug logging, false to disable.

Common use-cases

Switch on debug information in JavaScript Console.

osb('debug', true):

Switch off debug information in JavaScript Console.

osb('debug', false):
[top]

osb('get', ...)

Returns the content of the payload of a particular tracker.

Usage

osb('get', callback);
osb('get', name, callback);

Parameters

parameter nametyperequireddescription
'get'stringyesName of command.
namestringnoName of payload you'd like to see, leave empty for everything, or 'event', 'page', 'ids'.
callbackJS functionyesCallback function(payload) that receives the payload.

Common use-cases

Get the entire payload and show it JSON stringified in the JavaScript console.

// Return entire payload
osb('get', function(payload) {
    console.log(JSON.stringify(payload));
});

Get the payload only of the event object.

// Return payload only for event
osb('get', 'event', function(payload) {
    console.log(JSON.stringify(payload));
});
[top]

osb('profile', ...)

Retrieve a profile based upon the current (cross-domain) user id cookie. A profile is a list of strings which translate into aspects known about the visitor, like viewer preference, location, age group, etc.

Based upon external (batch) processes these profiles can be created and updated using information gathered while the user is browsing the website.

Usage

osb('profile', callback);

Parameters

parameter nametyperequireddescription
'profile'stringyesName of command.
callbackJS functionnoCallback function that will be called with the cross-domain user id and public profile of the visitor (an array of strings).

Common use-cases

Get the user profile and log it in the JavaScript console of the browser. Handy for development purposes.

osb('profile', function(cduid, profile) {
    /* Profile is a list of strings which translate into various aspects */
    console.log(`Profile for ${cduid} = ${JSON.stringify(profile)}`);
});

Get the user profile and change the HTML accordingly. Typical use-case for onsite targeting.

osb('profile', function(cduid, profile) {
    /* Change the HTML of the current page, based on various aspects of the profile */
    if (profile && profile.indexOf('youth') >= 0) {
        changeHTML(profile);
    }
});
[top]

osb('remove', ...)

Removes additional payload data. It will no longer be sent along with requests.

Usage

osb('remove', name);

Parameters

parameter nametyperequireddescription
'remove'stringyesName of command.
namestringyesName of object or array to remove.

Common use-cases

Sets and then removes the ids object. Use this if you only want the ids to be sent in a single hit.

osb('set', 'ids', { ... });
osb('send', 'ids');
osb('remove', 'ids');
[top]

osb('reset')

Resets all payloads.

Usage

osb('reset');

Parameters

parameter nametyperequireddescription
'reset'stringyesName of command.

Common use-cases

Resets all payloads.

osb('set', 'ids', { ... });
osb('set', 'page', { ... });
osb('reset');
[top]

osb('send', ...)

Sends a hit to the analytics server, like a pageview or an event.

Usage

osb('send', 'pageview', { options });
osb('send', 'event', { options });
osb('send', 'action', subtype, { options });
osb('send', 'ids', { options });

Parameters

parameter nametyperequireddescription
'send'stringyesName of command.
typestringyesSpecifies the type to send. You can use:
  • 'action'
  • 'ids'
  • 'event'
  • 'impression'
  • 'pageview'
  • 'viewable_impression'

The type will be stored in column hit_type, except for 'action', where sub_type will be stored instead.

If the command is 'impression' or 'viewable_impression', interaction is set to false, which implies this hit is not considered during sessionization.

subtypestringyes if type equals 'action'You can use your own hit_types, e.g. command queue (detail, add, remove, checkout, checkout_option, purchase, refund or promo_click), or use your own action as long as they only contain letters, numbers and/or underscores. The given subtype will be stored in the hit_type column.
{ options }JS objectnoContains type specific data. If you want to set additional payloads, or use them in multiple osb('send', ...) commands, then use the osb('set', ... ) command. Choose one of the following:

Common use-cases

Set additional payload from a <meta> tag on the page. If the page contains:

<meta name="article-id" content="12345">

You can get the information with:

osb('send', 'pageview', {
    'id': 'meta:article-id' // '12345'
});

Add the Google Analytics client id to the ids array and sends it immediately. Will show up with hit_type='ids' in hits table.

osb('send', 'ids', {
    key: '_ga',
    value: 'cookie:_ga' // 'GA1.2.123456789.1612345678'
});

Set multiple products in a single command and send those items together with the action. Typically on a thank-you page during e-commerce checkout. The value affiliation will be added to the data array of objects.

osb('set', 'items', [{
    id: 'sku123',
    name: 'Apple iPhone 14 Pro',
    category: 'mobile',
    price: 1234.56,
    quantity: 1
}, {
    id: 'sku234',
    name: 'Samsung Galaxy S22',
    category: 'mobile',
    price: 1034.56,
    quantity: 1
}]);
osb('send', 'action', {
    id: 'abcd1234',
    revenue: 2269.12,
    tax: (2269.12 * 0.21),
    shipping: 100,
    affiliation: 'partner_funnel'
});
[top]

osb('show', ...)

Returns the payload and config the tracker as a JSON object. Useful for debugging.

Usage

osb('show', function (response) {
    console.log(JSON.stringify(response));
});

Parameters

nametyperequireddescription
'show'stringyesName of command.
callbackJS functionNoCallback function(response) with the response with all the data. If not specified will output the response to the browser's console.

Common use-cases

Shows the meta information of the current tracker.

// Display everything in JavaScript developer console
osb('show');

// Display only the version
osb('show', function(response) {
    console.log(`Version = ${response.version}`);
});
[top]

osb('uid', ...)

Retrieves the cross-domain user-id (or domain user-id if not available) and calls a function with this UID as a parameter.

Usage

osb('uid', callback);

Parameters

parameter nametyperequireddescription
'uid'stringyesName of command.
callbackfunctionnoCallback function(uid) that receives cross-domain or domain user-id as a parameter. If no callback is specified, the UID will be logged to the console.

Common use-cases

Retrieves the user_id.

osb('uid', function(uid) {
    console.log('UID = ' + uid);
}):
[top]

Options

There are two categories of options:

Configuration options

Configuration options can only be set with the config command. They are meant to configure the tracker and are not stored in your database.

Example usage

osb('config', { 
    cookieDomain: 'mydomain.com',
    cookieNamePrefix: '_osb_',
    cookiePath: '/',
    cookieSettings: 1,
    siteId: 'mygreatsite',
    forceGET: false,
    ipSettings: 0,
    userCookieTimeout: 31536000
});

Properties

propertytypedefault valuedescription
cookieDomainstringDepends on domain name / host HTTP request headerFirst party cookie domain. Default is final two '.' separated parts of the requesting domain name.
cookieNamePrefixstring'_osb_'Prefix of all OSB Analytics cookies.
cookiePathstring'/'Cookie path.
cookieSettingsnumeric1Which cookie settings to use, see below for an overview.
forceGETbooleanfalseTrue forces the tracker to use an HTTP GET rather than POST method.
ipSettingsnumeric0Which IP settings to use, see below for an overview.
siteIdstringNoneSite ID, to distinguish which site sends the hit. Especially useful if your site spans multiple domain names or you want to categorize hits of the same domain.
userCookieTimeoutnumeric31536000Timeout of the user cookie in seconds. Default is 1 year.
cookie settingsdescription
0Saves cross domain user id first party using an external JavaScript file if necessary (in ancient browsers).
1Saves cross domain user id first party using XmlHttpRequest / fetch (default).
2Do not save cross domain user id first party using JavaScript.
3Do not save any cookies, either first or third party.

IP settings

IP settingsdescription
0Entire IP address will be saved.
1Last octet of the IPv4 address will be removed before storing (but used for country, city matching). E.g. 12.34.56.78 will be stored as 12.34.56.0.
2Entire IP address will be saved in a hashed format.
3IP address will be saved as 'hidden'.

Data options

Data options can be set along its corresponding command (action, event, ids, item or pageview) or set with the set or add commands. With set, no hit is sent to the server, whereas with send a hit is sent to the server.

Dynamic options

By prefixing a data value it is possible to substitute certain values before they are being set in the respective payload. The following prefixes are supported:

prefixdescription
'cookie:'Retrieve the value of the cookie with the given name. If the cookie is not set, the entire key/value pair is removed from the payload.
'meta:'Retrieve the content attribute of the <meta> element with the given name. If not found, the entire key/value pair is removed from the payload.
'local:'Retrieve a value from localStorage.
'query:'Extract the querystring parameter with the given name.
'session:'Retrieve a value from sessionStorage.
'url:'If the URL returns an HTTP 200 OK status and a JSON response, the value of the key in this response.
Use a JS functionInstead of prefixing the value string, provide a JavaScript function() that will return the value.

Examples

// Retrieve Google Analytics cookie
osb('add', 'ids', {
    key: '_ga',
    value: 'cookie:_ga' // 'GA1.2.123456789.1612345678'
});

// Given a <meta name="article-id" content="12345"> tag, retrieve its value
osb('send', 'pageview', {
    'id': 'meta:article-id' // '12345'
});

// local/session storage
sessionStorage.setItem('username', 'john.doe@example.com');
localStorage.setItem('name', 'John Doe');
osb('add', 'ids', {
    name: 'local:name',
    email: 'session:email'
});

// Given a URL /search?q=iPhone
osb('send', 'pageview', {
    search_term: 'query:q' // iPhone
});

// Given a response {"some_id":1234567890}
osb('set', 'ids', {
    some_id: 'url:https://api.example.com/get_some_id'
});

// Given a JS function
osb('set', 'page', {
    random: function() { return Math.random(); }
});
[top]

Data options: action

Contains the options of an action. Actions are typically used to track ecommerce actions like purchase or checkout. It will populate the action object (Snowflake) or struct (BigQuery) in the Analytics hits table.

Supported commands

The following commands support the parameters:

  • set · Sets the action object (Snowflake) or Struct (BigQuery) in the current payload, but doesn't send the information to the server.
  • send 'action' · Sets the action object and sends the information. Will show up in the destination table with hit_type=[value of subtype].

Parameters

nametypedefault valuedescription
idstringnullOrder or transaction id.
revenuefloatnull Total revenue amount.
shippingfloatnullShipping amount.
taxfloatnullTax amount.
any otherstringnullCustom data key/value pairs (up to 50 per action). Will be stored in the data array of the Analytics hits table.
[top]

Contains the consent value.

The following commands support the parameters:

  • set · Sets the consent value in the current payload, but doesn't send it to the server.
  • add · Adds a consent value to the existing consent array.

The value can be sent as a string or an array, not as a JavaScript object as with other payload data.

typedefault valuedescription
array or stringnullConsent value like 'all' or ['necessary','advertising'] or a valid TC String (IAB Europe) from us as a provider, like: CPUP3OWPUP3OWFjAOBENChCsAP_-AH_-ABpaxK...
[top]

Data options: event

Contains the options of an event. Will populate the event object (Snowflake) or struct (BigQuery) in the Analytics tables.

Supported commands

The following commands support the parameters:

  • set · Sets the event object (Snowflake) or Struct (BigQuery) in the current payload, but doesn't send the information to the server.
  • send 'event' · Sets the event object and sends the information. Will show up in the destination table with hit_type=event.

Parameters

nametypedefault valuedescription
categorystringnullContains the event category, e.g. consent.
actionstringnullContains the event action, e.g. show.
labelstringnullContains the event label, e.g wall.
valuenumbernullContains the event value, e.g. 2.0.
interactionbooleannull (or true)Contains if the event should be considered an interaction. If true, the hit will be sessionized. If false the hit will not be sessionized.
any otherstringnullCustom data key/value pairs (up to 50 per action). Will be stored in the data array of the Analytics hits table.
[top]

Data options: ids

Contains the options of ids. Will populate the ids array in the Analytics tables.

Supported commands

The following commands support the parameters:

  • add · Adds a single ids object to the ids array
  • set · Sets the ids array in a single statement
  • send 'ids' · Sets the ids array in a single statement and sends the information. Will show up in the destination table with hit_type=ids.

Parameters

nametypedefault valuedescription
keystringnullContains the key of the id, e.g. _ga.
valuestringnullContains the id, e.g. 123456789.987654321.
labelstringnullUse this if you want to use the same key in different situations. E.g. a _ga cookie value for different accounts on the same web page.
hashbooleannullUse this if you want Analytics to hash your value in-memory before storing it in the database, e.g. for email addresses or phone numbers. Hashing is done with SHA256(salt + ':' + value) where salt is account specific and can be retrieved from the Onesecondbefore Console (with proper permissions). So if the salt is OSB and the email address is test@onesecondbefore.com, use this statement in BigQuery to calculate the hash: SELECT TO_HEX(SHA256('OSB:test@onesecondbefore.com')) (which would be 'c2ddd2d48ea0889b95b6e2750624b9690deb4feacdc6ef81195b17138c989496').
[top]

Data options: items

Contains the options of items. Will populate the items array in the Analytics tables.

Supported commands

The following commands support the parameters:

  • add · Adds a single item object to the items array
  • set · Sets the items array with a single statement

Parameters

nametypedefault valuedescription
idstringnullProduct id or sku.
namestringnullProduct name.
categorystringnullProduct category.
pricefloatnullProduct price.
quantityfloatnullProduct quantity.
any otherstringnullCustom data key/value pairs (up to 50 per action). Will be stored in the data array of the Analytics hits.action.items.data table.
[top]

Data options: page

Contains the options of a page. Will populate the page object (Snowflake) or struct (BigQuery) in the Analytics tables.

Supported commands

The following commands support the parameters:

  • set · Sets the page object (Snowflake) or Struct (BigQuery) in the current payload, but doesn't send the information to the server.
  • send 'pageview' · Sets the page object and sends the information. Will show up in the destination table with hit_type=pageview.

Parameters

nametypedefault valuedescription
titlestringJS: document.titleTitle of the page.
idstringnullUnique id of the page in the Content Management System.
urlstringJS: location.hrefURL of the page, in case you want to override the default. If the value starts with the protocol (e.g. http), it is considered a full URL. If the value starts with a slash (/), everything from the path (including query string and fragment) will be overwritten. If the value starts with a question mark (?), everything after the query string (including the fragment) will be overwritten. If the value starts with a hash (#), everything after the fragment will be overwritten.
referrerstringJS: document.referrerURL of the referrer, in case you want to override the default. If the value starts with the protocol (e.g. http), it is considered a full URL. If the value starts with a slash (/), everything from the path (including query string and fragment) will be overwritten. If the value starts with a question mark (?), everything after the query string (including the fragment) will be overwritten. If the value starts with a hash (#), everything after the fragment will be overwritten.
osc_idstringnullOn-site campaign identifier.
osc_labelstringnullAn extra label in case the on-site campaign identifier alone is not enough.
oss_keywordstringnullOn-site search query / keyword.
oss_categorystringnullOn-site search category.
oss_total_resultsintegernullOn-site search total number of search results.
oss_results_per_pageintegernullOn-site search number of search results per result page.
oss_current_pageintegernullOn-site search result current page number.
any otherstringnullCustom data key/value pairs (up to 50 per action). Will be stored in the data array of the Analytics hits table.
[top]