Last active
November 8, 2022 03:45
-
-
Save mnoskov/f3e9f448c55a2063fd559d295dc9a1fe to your computer and use it in GitHub Desktop.
VK Dynamic Retargeting INSALES
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Просмотр товара: | |
// Добавить в шаблон "product.liquid" код | |
<script> | |
$(window).load(function() { | |
var prices = [<Список идентификаторов прайс-листов>]; | |
for (var i = 0; i < prices.length; i++) { | |
VK.Retargeting.ProductEvent(prices[i], 'view_product', { | |
products: [ | |
{id: '{{ product.id }}'} | |
], | |
total_price: '{{ product.price }}' | |
}); | |
} | |
}); | |
</script> | |
// Добавление товара в корзину: | |
// Добавить код в разделе "Счетчики и коды" в настройках сайта, в поле "Вставка на всех страницах" | |
<script> | |
$(window).load(function() { | |
if (Cart.tasks._add) { | |
var originalCartAdd = Cart.tasks._add; | |
Cart.tasks._add = function() { | |
try { | |
if (VK.Retargeting && arguments[0] && arguments[0].items) { | |
for (var product_id in arguments[0].items) { | |
var prices = [<Список идентификаторов прайс-листов>]; | |
for (var i = 0; i < prices.length; i++) { | |
VK.Retargeting.ProductEvent(prices[i], 'add_to_cart', { | |
products: [ | |
{id: product_id} | |
] | |
}); | |
} | |
} | |
} | |
} catch (e) { } | |
return originalCartAdd.apply(this, arguments); | |
} | |
} | |
}); | |
</script> | |
// Совершение покупки: | |
// Добавить код в разделе "Счетчики и коды" в настройках сайта, в поле "Вставка на странице успешного оформления заказа" | |
<script> | |
$(window).load(function() { | |
var prices = [<Список идентификаторов прайс-листов>]; | |
for (var i = 0; i < prices.length; i++) { | |
VK.Retargeting.ProductEvent(prices[i], 'purchase'); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment