1.Replace the Pixel ID in the code provided by Yahoo with the sample code below. Character 10120000 (4 parts) in the following code needs to be replaced with the Pixel ID in the code provided by Yahoo.
<script type="text/javascript">
(function (w, d, t, r, u) {
w[u] = w[u] || [];
w[u].push({
'projectId': '10000',
'properties': {
'pixelId': '10120000'
}
});
var s = d.createElement(t);
s.src = r;
s.async = true;
s.onload = s.onreadystatechange = function () {
var y, rs = this.readyState,
c = w[u];
if (rs && rs != "complete" && rs != "loaded") {
return
}
try {
y = YAHOO.ywa.I13N.fireBeacon;
w[u] = [];
w[u].push = function (p) {
y([p])
};
y(c)
} catch (e) {}
};
var scr = d.getElementsByTagName(t)[0],
par = scr.parentNode;
par.insertBefore(s, scr)
})(window, document, "script", "https://s.yimg.com/wi/ytc.js", "dotq");
$(function () {
window.dotq = window.dotq || [];
// 產品頁面
$(document.body).on('dj.viewContent', function (e, data) {
window.dotq.push({
'projectId': '10000',
'properties': {
'pixelId': '10120000',
'qstrings': {
'et': 'custom',
'ea': 'ViewProduct',
'product_id': data.product.id
}
}
});
});
// 加入購物車頁面
$(document.body).on('dj.addToCart', function (e, v) {
window.dotq.push({
'projectId': '10000',
'properties': {
'pixelId': '10120000',
'qstrings': {
'et': 'custom',
'ea': 'AddToCart',
'gv': Number(v.item_price) * Number(v.number || 1),
'product_id': v.id
}
}
});
});
// 購買完成頁面
$(document.body).on("dj.purchase", function (e, v) {
v.line_items.map(function (item) {
window.dotq.push({
'projectId': '10000',
'properties': {
'pixelId': '10120000',
'qstrings': {
'et': 'custom',
'ea': 'Purchase',
'gv': Number(item.total),
'product_id': item.product_id
}
}
});
});
})
})
</script>
2.If you want to get the Variant ID instead of the Product ID, use the following code. Character 10120000 (4 parts) in the following code needs to be replaced with Pixel ID in the code provided by Yahoo.
<script type="text/javascript">
(function (w, d, t, r, u) {
w[u] = w[u] || [];
w[u].push({
'projectId': '10000',
'properties': {
'pixelId': '10120000'
}
});
var s = d.createElement(t);
s.src = r;
s.async = true;
s.onload = s.onreadystatechange = function () {
var y, rs = this.readyState,
c = w[u];
if (rs && rs != "complete" && rs != "loaded") {
return
}
try {
y = YAHOO.ywa.I13N.fireBeacon;
w[u] = [];
w[u].push = function (p) {
y([p])
};
y(c)
} catch (e) {}
};
var scr = d.getElementsByTagName(t)[0],
par = scr.parentNode;
par.insertBefore(s, scr)
})(window, document, "script", "https://s.yimg.com/wi/ytc.js", "dotq");
$(function () {
window.dotq = window.dotq || [];
// 產品頁面
$(document.body).on('dj.viewContent', function (e, data) {
window.dotq.push({
'projectId': '10000',
'properties': {
'pixelId': '10120000',
'qstrings': {
'et': 'custom',
'ea': 'ViewProduct',
'product_id': data.selected && data.selected.id
}
}
});
});
// 加入購物車頁面
$(document.body).on('dj.addToCart', function (e, v) {
window.dotq.push({
'projectId': '10000',
'properties': {
'pixelId': '10120000',
'qstrings': {
'et': 'custom',
'ea': 'AddToCart',
'gv': Number(v.item_price) * Number(v.number || 1),
'product_id': v.variant_id
}
}
});
});
// 購買完成頁面
$(document.body).on("dj.purchase", function (e, v) {
v.line_items.map(function (item) {
window.dotq.push({
'projectId': '10000',
'properties': {
'pixelId': '10120000',
'qstrings': {
'et': 'custom',
'ea': 'Purchase',
'gv': Number(item.total),
'product_id': item.variant_id
}
}
});
});
})
})
</script>
3.After making the replacement, add the code to "Custom code" from the SHOPLAZZA App Store, Choose “PC & Mobile”, for “All” pages. Select “Top” to locate the code.
Comments
Article is closed for comments.