Breadcrumbs

Web SDK Integration

Choose your Web SDK script

The Utiq Web SDK (utiqCore) is a single lightweight script that reads consent, identifies eligible users and exposes Utiq IDs through one event and one method. It replaces the legacy utiqLoader.js. Pick the script that matches how your CMP handles Utiq consent:

Your setup

Script

How Utiq gets consent

Your site uses a TCF CMP

utiqCore-tcf.js (required)

Read automatically from your CMP for Utiq (GVL vendor ID 1643) via the TCF API - no consent code needed

Your site doesn't use a TCF CMP

utiqCore-custom.js

You pass the user's choice to the Utiq custom vendor with window.Utiq.Core.setConsent(true / false)

You want Utiq to show its own consent pop-up (Separate pop-up model)

utiqPopup.js

Coming soon. Until it is released, keep using the Separate pop-up model with utiqLoader.js

The deciding factor is whether your site uses TCF. If it does, you must use utiqCore-tcf.js and add Utiq (vendor ID 1643) to your CMP - keeping Utiq as a custom vendor inside a TCF CMP is no longer supported.

Already running utiqLoader.js? Read Migrating from utiqLoader.js before you start - the two scripts are not compatible and nothing from the old integration should be kept.

Before you start

You need two things in place before adding the script. Contact onboard@utiq.com if any are missing.

  1. Your Utiq host: Utiq is served from a subdomain of your site, set up during onboarding (for example utiq.example.com for example.com). If your old integration used window.Utiq.config.customUtiqHost, use that value.

  2. Your CMP configured for Utiq: Please see the ‘Requirements for Advertisers and Publishers (v5.0) - Integrating Utiq consent’ guide.

If you use TCF: utiqCore-tcf.js

With utiqCore-tcf.js, Utiq reads consent for vendor 1643 directly from your CMP. You only add the script and read IDs.

Step 1 - Add the script

Add the script to every page of your site, replacing utiq.example.com with your Utiq host:

HTML
<script>
  <!-- Get utiqPurposeConsent and utiqVendorConsent from the CMP -->
  window.Utiq.TCF ||= {};
  window.Utiq.TCF.getCustomPurposeStatus = () => { return true } // or false
  window.Utiq.TCF.getCustomVendorStatus = () => { return true } // or false
</script>
<script
  type="text/javascript"
  src="https://utiq.example.com/utiqCore-tcf.js"
  data-utiq-host="utiq.example.com"
  async
></script>

If you load scripts programmatically (for example from a tag manager):

JavaScript
// Get utiqPurposeConsent and utiqVendorConsent from the CMP
window.Utiq.TCF ||= {};
window.Utiq.TCF.getCustomPurposeStatus = () => { return true } // or false
window.Utiq.TCF.getCustomVendorStatus = () => { return true } // or false

const el = document.createElement('script');
el.type = 'text/javascript';
el.src = 'https://utiq.example.com/utiqCore-tcf.js';
el.dataset.utiqHost = 'utiq.example.com';
el.async = true;
document.head.appendChild(el);

You don't need to wait for consent or call any Utiq method when the user changes their choice in the CMP - utiqCore-tcf.js picks up the change itself.

Step 2 - Read IDs

See Read Utiq IDs below.

If you don't use TCF: utiqCore-custom.js

With utiqCore-custom.js, your site tells Utiq whether the user consented to the Utiq custom vendor and purpose in your CMP.

Step 1 - Add the script

Add the script to every page of your site, replacing utiq.example.com with your Utiq host:

HTML
<script
  type="text/javascript"
  src="https://utiq.example.com/utiqCore-custom.js"
  data-utiq-host="utiq.example.com"
  async
></script>

If you load scripts programmatically (for example from a tag manager):

JavaScript
const el = document.createElement('script');
el.type = 'text/javascript';
el.src = 'https://utiq.example.com/utiqCore-custom.js';
el.dataset.utiqHost = 'utiq.example.com';
el.async = true;
document.head.appendChild(el);

Call setConsent with the user's Utiq choice, as a boolean:

JavaScript
window.Utiq ||= {};
window.Utiq.queue ||= [];
window.Utiq.queue.push(() => {
  window.Utiq.Core.setConsent(true); // or false when the user rejects or withdraws
});

Call it only when you have new consent information - when the user accepts, rejects or changes their choice in your CMP. Each call clears Utiq's local TTL and sends a network request to check whether the user needs to be re-identified. Calling it on every page view or on every CMP event overloads Utiq's servers and degrades the service.

A typical pattern is to call setConsent from your CMP's "consent saved" callback, and only when the Utiq value differs from the last value you sent.

Step 3 - Read IDs

See Read Utiq IDs below.

Read Utiq IDs

Both scripts expose the same event and method for reading IDs:

Name

Type

What it does

window.Utiq.Core.onChange(callback)

Event

Fires when something changed and Utiq may have updated the ID graph

window.Utiq.Core.getIdGraphEntry(entry)

Method

Returns Utiq IDs and their attributes - same parameters and return values as the legacy getIdGraphEntry

Register through window.Utiq.queue, so your code works whichever script loads first:

JavaScript
window.Utiq ||= {};
window.Utiq.queue ||= [];
window.Utiq.queue.push(() => {
  window.Utiq.Core.onChange(() => {
    const allPasses = window.Utiq.Core.getIdGraphEntry([]); // all connections
    const atid = window.Utiq.Core.getIdGraphEntry('atid'); // latest connection
    const mtids = window.Utiq.Core.getIdGraphEntry(['mtid']); // mtid of all
  });
});

For the list of passes (mtid, atid, attrid, category, ttl, domain) and multi-connection behavior, see Retrieving Utiq IDs.

onChange can fire more than once

onChange may fire several times per page, even when nothing changed. Writing the IDs to storage or a variable on every call is fine. If you trigger something with a cost - a network request, an ad call, an analytics event - you must check that the value actually changed:

JavaScript
window.Utiq ||= {};
window.Utiq.queue ||= [];

let lastAtid = '';
window.Utiq.queue.push(() => {
  window.Utiq.Core.onChange(() => {
    const atid = window.Utiq.Core.getIdGraphEntry('atid');
    if (atid !== lastAtid) {   // act only on a real change
      lastAtid = atid;
      sendIdsToYourBackend(atid);
    }
  });
});

Validate your integration

Your integration is complete when all three checks pass on an eligible connection:

  • The script loads from your Utiq host on every page, with no console errors.

  • After consent, window.Utiq.Core.getIdGraphEntry([]) returns the expected IDs; after rejection or withdrawal, it returns none.

  • Nothing downstream over-triggers: requests or events tied to onChange fire once per real ID change, not on every onChange call.

See Testing Web Integration for how to test on an eligible network.

Migrating from utiqLoader.js

utiqCore replaces utiqLoader.js and is not compatible with it: remove every part of the old integration, then integrate utiqCore as described above. The API shrinks from 7 events and 13 methods to 1 event and 1-2 methods, under a new namespace (window.Utiq.Core instead of window.Utiq.API).

TCF properties must move to utiqCore-tcf.js

What changes

utiqLoader.js

utiqCore-tcf.js / utiqCore-custom.js

Loaded on every page; consent comes from custom purpose / vendor and handleConsentChange

Loaded on every page; consent comes from TCF (-tcf) or setConsent (-custom)

window.Utiq.config (incl. customUtiqHost), setConfig, getConfig

Removed. The host is set with the data-utiq-host attribute

handleConsentChange(true / false)

With utiqCore-custom.js: replaced by setConsent(true / false). With utiqCore-tcf.js: not needed - consent is read from your CMP

onIdsAvailable

onChange + getIdGraphEntry

onInitialised, onEligibilityChecked, onConsentChanging, onConsentUpdateFinished, onFlowCompleted

Removed. Use onChange

addEventListener, removeEventListener

Replaced by window.Utiq.Core.onChange

getIdGraphEntry

window.Utiq.Core.getIdGraphEntry - same parameters and return values

showConsentManager, onConsentManagerStatusChanged, customizationOptions

Removed. Utiq-hosted pop-up moves to the upcoming utiqPopup.js

showConsentModal, revokeConsentWithPopup

Removed

handleDataClear, getUtiqConsentStatus

Removed. Data is cleared when consent is withdrawn

setLogLevel, resetLoggingLevel

Removed. Logging level is set with the data-verbose="true" attribute or ?utiqVerbose=true query

One behavior change needs care: each utiqLoader events fired only under certain conditions (for example, onInitialised once per session). onChange can fire repeatedly with no change. Any code you move from onIdsAvailable to onChange that sends requests must be deduplicates - see onChange can fire more than once.

Migration steps

  1. Audit your current integration: Note your Utiq host (customUtiqHost, if set), every place that listens to Utiq events or calls window.Utiq.API, and where the IDs go (Prebid, Ad Server, Analytics, your Backend, etc.).

  2. Configure your CMP - see Before you start.

  3. Remove utiqLoader.js - the script tag or tag manager tag, any consent-gating wrapper around it, window.Utiq.config, and all window.Utiq.API calls.

  4. Add the utiqCore script for your setup - TCF or custom - and, for custom, integratie setConsent to your CMP.

  5. Reconnect your ID consumers to onChange + getIdGraphEntry, deduplicating anything that sends requests.

  6. Validate - see Validate your integration.