Files
kupshop/web/templates/elnino/block.fbpixel.tpl
2025-08-02 16:30:27 +02:00

32 lines
1.1 KiB
Smarty

{switch $pageType}
{case "product"}
<script>
// facebook pixel, posila se po zvoleni aktivovani konkretni varianty
var sendPixel = function() {
var variation = $('.product-variations [data-variation-id].active'),
varId = variation.data('variation-id'),
price = { },
code = variation.data('code');
{foreach $body.product.variations.variations as $id => $var}
price[{$id}] = {$var.price.price_with_vat} ;
{/foreach}
if (variation.find('[data-buy-form]').length) {
fbq('track', 'ViewContent', {
content_ids: [ code ],
content_type: 'product',
currency: '{$ctrl.currency|default:$dbcfg.currency_code}',
value: price[varId]
});
}
};
sendPixel();
$('.product-variations').on('click', '[data-variation-id]:not(.active)', sendPixel);
</script>
{/case}
{/switch}