Articoli su: Integrazioni
Questo articolo è disponibile anche in:

Come implementare UET Microsoft Consent Mode nel checkout

Questa guida ti aiuterà ad attivare Microsoft Consent Mode nel checkout, così potrai tracciare gli eventi del checkout con il consenso dell'utente.


Scopo

Devi avere Microsoft consent mode implementato nel tuo negozio se vendi nell'UE e tracci utenti del SEE. Microsoft sta addirittura disattivando le campagne che non seguono questo nuovo standard.


Come funziona con la nostra integrazione

Sebbene Pandectes GDPR offra un'integrazione diretta per Microsoft Consent Mode, come sai checkout extensibility non consente l'esecuzione di script di app nel checkout.
Quindi il custom pixel qui sotto ti permetterà di inviare il consenso a Microsoft e di tracciare l'evento di acquisto nel checkout con il consenso!


In sostanza, l'integrazione Pandectes e il Pixel lavorano in tandem: l'integrazione copre l'intero negozio, mentre il Pixel gestisce il checkout.


Integrazione:

Vai su Shopify Settings > Customer Events. Poi fai clic su "Add Custom pixel"



Dagli un bel nome e fai clic su "Add pixel"



Imposta il permesso su "Not required"



E incolla il codice seguente nella sezione del codice:


// Pandectes Pixel for Microsoft UET consent mode and events tracking

const uetTagId = '' // Input your UET tag Id
const DENIED = "denied"
const GRANTED = "granted"
const STORE_POLICY = DENIED; // You can change to GRANTED if you would like to have a loose policy

const getCookie = (cookieName) => {
const cookieString = document.cookie;
const cookieStart = cookieString.indexOf(cookieName + "=");
if (cookieStart === -1) {
return null;
}
let cookieEnd = cookieString.indexOf(";", cookieStart);
if (cookieEnd === -1) {
cookieEnd = cookieString.length;
}
const cookieValue = cookieString.substring(cookieStart + cookieName.length + 1, cookieEnd);
try {
const decodedValue = atob(cookieValue);
const parsedValue = JSON.parse(decodedValue);
return parsedValue;
} catch (error) {
console.error("Error parsing cookie value:", error);
return null;
}
};

function setCookie(name, value, days) {
const date = new Date();
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
const expires = 'expires=' + date.toUTCString();
document.cookie = `${name}=${value}; ${expires}; path=/; secure; samesite=strict`;
}

const getStorage = (preferences) => {
const p4 = (preferences &4) === 0;
output = {
ad_storage: p4 ? GRANTED : DENIED
}
return output;
}

if (window.location.href.includes("/checkout/") ||window.location.href.includes("/checkouts/")){
window.uetq = window.uetq || [];

const cookie = getCookie("_pandectes_gdpr");
const defaultStorage = getStorage(STORE_POLICY === DENIED ? 7:0);
STORE_POLICY===DENIED ? setCookie('_uetmsdns', '1', 365) : setCookie('_uetmsdns', '0', 365);
window.uetq.push('consent', 'default', defaultStorage);

if (cookie && cookie.preferences !== null && cookie.preferences !== undefined) {
const updateStorage = getStorage(cookie.preferences);
window.uetq.push('consent', 'update', updateStorage);
if (updateStorage.ad_storage==GRANTED) {
setCookie('_uetmsdns', '0', 365);
}
}

/*

* UET tag Initialization
*/
(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:uetTagId, disableAutoPageView: true, enableAutoSpaTracking: false};o.q=w[u],w[u]=new UET(o),w[u].push("pageLoad")},n=d.createElement(t),n.src=r,n.async=1,n.onload=n.onreadystatechange=function(){var s=this.readyState;s&&s!=="loaded"&&s!=="complete"||(f(),n.onload=n.onreadystatechange=null)},i=d.getElementsByTagName(t)[0],i.parentNode.insertBefore(n,i)})(window,document,"script","//bat.bing.com/bat.js","uetq");

/*

* Events Tracking
*/

analytics.subscribe("page_viewed", (event) => {
window.uetq.push('event', 'page_view', { 'page_location': event.context.window.location.href });
});

analytics.subscribe("checkout_completed", event => {

let productIds = '';
let revenueValue = 0;
let currency = '';

if (event.data?.checkout) {
revenueValue = event.data.checkout.totalPrice?.amount;
currency = event.data.checkout.totalPrice?.currencyCode;

if (Array.isArray(event.data?.checkout?.lineItems)) {
const lineItemIds = event.data.checkout.lineItems.map(item => String(item.variant.product.id));
productIds = lineItemIds.join(',').slice(0, 50);
}

window.uetq.push('event', 'purchase', {
'ecomm_prodid': productIds,
'ecomm_pagetype': 'purchase',
'revenue_value': revenueValue,
'currency': currency
});
}
});

}


Devi aggiungere in alto l'ID del tuo tag UET, in modo che gli eventi vengano inviati al tuo tag, e fare clic su Connect.



Ed è tutto pronto! Ora il pixel leggerà il cookie di Pandectes per conoscere lo stato del consenso, lo comunicherà a Microsoft e traccerà l'evento!

Aggiornato il: 20/10/2026

È stato utile questo articolo?

Condividi il tuo feedback

Annulla

Grazie!