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 |
|
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 |
|
You pass the user's choice to the Utiq custom vendor with |
|
You want Utiq to show its own consent pop-up (Separate pop-up model) |
|
Coming soon. Until it is released, keep using the Separate pop-up model with |
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.
-
Your Utiq host: Utiq is served from a subdomain of your site, set up during onboarding (for example
utiq.example.comforexample.com). If your old integration usedwindow.Utiq.config.customUtiqHost, use that value. -
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:
<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):
// 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:
<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):
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);
Step 2 - Provide consent
Call setConsent with the user's Utiq choice, as a boolean:
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 |
|---|---|---|
|
|
Event |
Fires when something changed and Utiq may have updated the ID graph |
|
|
Method |
Returns Utiq IDs and their attributes - same parameters and return values as the legacy |
Register through window.Utiq.queue, so your code works whichever script loads first:
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:
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
onChangefire once per real ID change, not on everyonChangecall.
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 |
Loaded on every page; consent comes from TCF ( |
|
|
Removed. The host is set with the |
|
|
With |
|
|
|
|
|
Removed. Use |
|
|
Replaced by |
|
|
|
|
|
Removed. Utiq-hosted pop-up moves to the upcoming |
|
|
Removed |
|
|
Removed. Data is cleared when consent is withdrawn |
|
|
Removed. Logging level is set with the |
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
-
Audit your current integration: Note your Utiq host (
customUtiqHost, if set), every place that listens to Utiq events or callswindow.Utiq.API, and where the IDs go (Prebid, Ad Server, Analytics, your Backend, etc.). -
Configure your CMP - see Before you start.
-
Remove
utiqLoader.js- the script tag or tag manager tag, any consent-gating wrapper around it,window.Utiq.config, and allwindow.Utiq.APIcalls. -
Add the
utiqCorescript for your setup - TCF or custom - and, for custom, integratiesetConsentto your CMP. -
Reconnect your ID consumers to
onChange+getIdGraphEntry, deduplicating anything that sends requests. -
Validate - see Validate your integration.