Skip to content

Instantly share code, notes, and snippets.

@apoleshchuk
Created April 26, 2019 12:42
Show Gist options
  • Save apoleshchuk/ad8da7780efd8eabfc04f74c8d7851bc to your computer and use it in GitHub Desktop.
Save apoleshchuk/ad8da7780efd8eabfc04f74c8d7851bc to your computer and use it in GitHub Desktop.
InSales dataLayer events
EventBus.subscribe("always:insales:cart", data => {
// Скрипт common_js добавляет события о корзине в `dataLayer`, но он не
// устанавливает поле `event` в его пэйлоаде, поэтому у GTM нет шансов
// зацепить изменения в `dataLayer`. Форсируем это самостоятельно.
if (window.dataLayer) {
setTimeout(() => window.dataLayer.push({ event: "cartChange" }), 50);
}
});
<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'checkout',
'ecommerce': {
'checkout': {
'actionField': { 'step': {{ checkout_datalayer_step }} },
'products': [
{{ checkout_datalayer_products }}
]
}
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment