[Changed] condition to trigger event-firing
This commit is contained in:
parent
2ec373c95f
commit
a18bcd35c4
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
[{if $d3CmpBasket && $d3CmpBasket->getAddToBasketDecision() && $d3CmpBasket->d3GtmRequestedArticleLoadedByAnid() !== null}]
|
[{if $d3CmpBasket && $d3CmpBasket->d3GtmRequestedArticleLoadedByAnid() !== null}]
|
||||||
[{assign var="oGtmProduct" value=$d3CmpBasket->d3GtmRequestedArticleLoadedByAnid()}]
|
[{assign var="oGtmProduct" value=$d3CmpBasket->d3GtmRequestedArticleLoadedByAnid()}]
|
||||||
[{assign var="oGtmAmountArticlesAdded" value=$d3CmpBasket->getD3GtmAddToCartAmountArticles()}]
|
[{assign var="oGtmAmountArticlesAdded" value=$d3CmpBasket->getD3GtmAddToCartAmountArticles()}]
|
||||||
[{*$smarty.block.parent*}]
|
[{*$smarty.block.parent*}]
|
||||||
@ -12,50 +12,50 @@
|
|||||||
[{block name="d3_ga4_add_to_cart_list_block"}]
|
[{block name="d3_ga4_add_to_cart_list_block"}]
|
||||||
[{capture name="d3_ga4_add_to_cart_listtpl"}]
|
[{capture name="d3_ga4_add_to_cart_listtpl"}]
|
||||||
[{strip}]
|
[{strip}]
|
||||||
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
|
|
||||||
|
|
||||||
[{*** Debug cases ***}]
|
$(document).ready(function() {
|
||||||
[{*event.preventDefault();*}]
|
$('#toBasket').on('click', function() {
|
||||||
|
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
|
||||||
|
|
||||||
let iArtQuantity = $("[{$htmlIdAmountOfArticles}]").val();
|
[{*** Debug cases ***}]
|
||||||
let iArtQuantityAdded = [{$oGtmAmountArticlesAdded}];
|
[{*event.preventDefault();*}]
|
||||||
|
|
||||||
if(!iArtQuantity && (iArtQuantityAdded === 1)){
|
let iArtQuantity = $("[{$htmlIdAmountOfArticles}]").val();
|
||||||
iArtQuantity = 1;
|
let iPriceValue = [{$d3PriceObject->getPrice()}];
|
||||||
}else{
|
let iSumPrice = iArtQuantity*iPriceValue;
|
||||||
iArtQuantity = iArtQuantityAdded;
|
|
||||||
}
|
|
||||||
|
|
||||||
dataLayer.push({
|
dataLayer.push({
|
||||||
'isAddToBasket': true,
|
'isAddToBasket': true,
|
||||||
'event':'add_to_cart',
|
'event':'add_to_cart',
|
||||||
'eventLabel': 'add_to_cart',
|
'eventLabel': 'add_to_cart',
|
||||||
'ecommerce': {
|
'ecommerce': {
|
||||||
'currency': "[{$currency->name}]",
|
'currency': "[{$currency->name}]",
|
||||||
'value': iArtQuantity*[{$d3PriceObject->getPrice()}],
|
'value': parseInt(iSumPrice.toFixed(2)),
|
||||||
'items': [
|
'items': [
|
||||||
{
|
{
|
||||||
'item_id': '[{$oGtmProduct->getFieldData('oxartnum')}]',
|
'item_id': '[{$oGtmProduct->getFieldData('oxartnum')}]',
|
||||||
'item_name': '[{$oGtmProduct->getFieldData('oxtitle')}]',
|
'item_name': '[{$oGtmProduct->getFieldData('oxtitle')}]',
|
||||||
'price': [{$d3PriceObject->getPrice()}],
|
'price': [{$d3PriceObject->getPrice()}],
|
||||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||||
'item_variant': '[{if $oGtmProduct->getFieldData('oxvarselect')}][{$oGtmProduct->getFieldData('oxvarselect')}][{/if}]',
|
'item_variant': '[{if $oGtmProduct->getFieldData('oxvarselect')}][{$oGtmProduct->getFieldData('oxvarselect')}][{/if}]',
|
||||||
[{if $gtmCategory}]
|
[{if $gtmCategory}]
|
||||||
'item_category': '[{$gtmCategory->getSplitCategoryArray(0, true)}]',
|
'item_category': '[{$gtmCategory->getSplitCategoryArray(0, true)}]',
|
||||||
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1, true)}]',
|
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1, true)}]',
|
||||||
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2, true)}]',
|
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2, true)}]',
|
||||||
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3, true)}]',
|
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3, true)}]',
|
||||||
'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]',
|
'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]',
|
||||||
[{/if}]
|
[{/if}]
|
||||||
'quantity': iArtQuantity
|
'quantity': iArtQuantity
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}[{if $oViewConf->isDebugModeOn()}],
|
}[{if $oViewConf->isDebugModeOn()}],
|
||||||
'debug_mode': 'true'
|
'debug_mode': 'true'
|
||||||
[{/if}]
|
[{/if}]
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
[{/strip}]
|
[{/strip}]
|
||||||
[{/capture}]
|
[{/capture}]
|
||||||
[{oxscript add=$smarty.capture.d3_ga4_add_to_cart_listtpl}]
|
[{oxscript add=$smarty.capture.d3_ga4_add_to_cart_listtpl}]
|
||||||
[{/block}]
|
[{/block}]
|
||||||
[{/if}]
|
[{/if}]
|
Loading…
Reference in New Issue
Block a user