For more details, you can find the complete guide on our Confluence page.
Please ensure that all tags are properly configured to comply with local privacy laws. It is important to follow your site's consent manager configuration in order to meet the necessary requirements.
analytics.subscribe('page_viewed', (event) => {
window.CYBurl = event.context.window.location.href;
if(document.cookie.replace(/(?:(?:^|.*;\s*)cart\s*\=\s*([^;]*).*$)|^.*$/, "$1") != ""){
window._vteq = window._vteq || [];
_vteq.push({
"update":{
"_vtsid": document.cookie.replace(/(?:(?:^|.*;\s*)cart\s*\=\s*([^;]*).*$)|^.*$/, "$1")
}});
}
!function(){if(!document.querySelector("[src*='XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX']")){window.e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="//www.rtb123.com/tags/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/btp.js";window.t=document.getElementsByTagName("head")[0];t?t.appendChild(e,t):(t=document.getElementsByTagName("script")[0]).parentNode.insertBefore(e,t)}}();
});
analytics.subscribe('checkout_completed', (event) => {
window.checkoutData = event.data.checkout;
window.orderedItems = event.data.checkout.lineItems;
window.cybOrderData = {
order_id: checkoutData.order.id,
value: checkoutData.totalPrice.amount,
currency: checkoutData.totalPrice.currencyCode,
productTitles: [],
itemData: []
};
orderedItems.forEach(function(element){
cybOrderData.itemData.push({ 'quantity': element.quantity, 'id': element.variant.sku });
cybOrderData.productTitles.push(element.title);
})
window._vteq = window._vteq || [];
window._vteq.push({
confirmation: {
items: cybOrderData.itemData,
orderId: cybOrderData.order_id,
total: cybOrderData.value,
generic: {
currency: cybOrderData.currency
}
}
});
});
analytics.subscribe('checkout_started', (event) => {
window.checkoutStep = event.name;
window.checkoutItems = event.data.checkout.lineItems;
window.checkoutTotal = event.data.checkout.subtotalPrice;
window.email = event.data.checkout.email;
window.cItems = [];
checkoutItems.forEach(function(element){
cItems.push(element.variant.sku);
})
window._vteq = window._vteq || [];
window._vteq.push({
checkout: {
step: checkoutStep,
items: cItems
}
});
window._vteq.push({
login: {
email: email
}
});
_vteq.push({
'event': {
'event_name': 'abandonmentTotal',
'total': checkoutTotal
}
});
});
analytics.subscribe('checkout_address_info_submitted', (event) => {
window.checkoutStep = event.name;
window.checkoutItems = event.data.checkout.lineItems;
window.checkoutTotal = event.data.checkout.subtotalPrice;
window.email = event.data.checkout.email;
window.cItems = [];
checkoutItems.forEach(function(element){
cItems.push(element.variant.sku);
})
window._vteq = window._vteq || [];
window._vteq.push({
checkout: {
step: checkoutStep,
items: cItems
}
});
window._vteq.push({
login: {
email: email
}
});
_vteq.push({
'event': {
'event_name': 'abandonmentTotal',
'total': checkoutTotal
}
});
});
analytics.subscribe('checkout_contact_info_submitted', (event) => {
window.checkoutStep = event.name;
window.checkoutItems = event.data.checkout.lineItems;
window.email = event.data.checkout.email;
window.checkoutTotal = event.data.checkout.subtotalPrice;
window.cItems = [];
checkoutItems.forEach(function(element){
cItems.push(element.variant.sku);
})
window._vteq = window._vteq || [];
window._vteq.push({
checkout: {
step: checkoutStep,
items: cItems
}
});
window._vteq.push({
login: {
email: email
}
});
_vteq.push({
'event': {
'event_name': 'abandonmentTotal',
'total': checkoutTotal
}
});
});
analytics.subscribe('checkout_shipping_info_submitted', (event) => {
window.checkoutStep = event.name;
window.checkoutItems = event.data.checkout.lineItems;
window.checkoutTotal = event.data.checkout.subtotalPrice;
window.email = event.data.checkout.email;
window.cItems = [];
checkoutItems.forEach(function(element){
cItems.push(element.variant.sku);
})
window._vteq = window._vteq || [];
window._vteq.push({
checkout: {
step: checkoutStep,
items: cItems
}
});
window._vteq.push({
login: {
email: email
}
});
_vteq.push({
'event': {
'event_name': 'abandonmentTotal',
'total': checkoutTotal
}
});
});
analytics.subscribe('cart_viewed', (event) => {
window.totalCartCost = event.data.cart.cost.totalAmount.amount;
window.cartItems = event.data.cart.lines;
window.pItems = [];
_vteq.push({
'event': {
'event_name': 'abandonmentTotal',
'total': totalCartCost
}
});
cartItems.forEach(function(element){
pItems.push({ 'ProductName': element.merchandise.product.title, 'Quantity': element.quantity, 'ProductImage': element.merchandise.image, 'ProductPrice': element.merchandise.price.amount, 'ProductSubtotal': element.cost, 'ProductSKU': element.merchandise.sku, 'ProductVariantName': element.merchandise.title, 'ProductVendor': element.merchandise.product.vendor, 'ProductType': element.merchandise.product.type, 'ProductURL': element.merchandise.product.url });
})
_vteq.push({
'event': {
'event_name': 'cart',
'items': pItems,
'shopifyCartID': event.data.cart.id
}
});
});
analytics.subscribe('product_added_to_cart', (event) => {
window.itemAddedSKU = event.data.cartLine.merchandise.sku;
window._vteq = window._vteq || [];
window._vteq.push({
addtocart: {
itemId: itemAddedSKU
}
});
});
analytics.subscribe('search_submitted', (event) => {
window.searchQuery = searchResult.query;
window._vteq = window._vteq || [];
window._vteq.push({
"search": {
query: searchQuery
}
});
});
analytics.subscribe('product_viewed', (event) => {
window.productSKU = event.data.productVariant.sku;
window._vteq = window._vteq || [];
window._vteq.push({
"viewitem": {
itemId: productSKU
}
});
});
analytics.subscribe('input_blurred', (event) => {
window.element = event.data.element;
window.elementValue = element.value;
if(!!~elementValue.indexOf("@")){
window._vteq = window._vteq || [];
window._vteq.push({
login: {
email: elementValue
}
});
}
});