diff --git a/view/frontend/templates/add-to-cart-event.phtml b/view/frontend/templates/add-to-cart-event.phtml index 97a933b..80b2d9f 100644 --- a/view/frontend/templates/add-to-cart-event.phtml +++ b/view/frontend/templates/add-to-cart-event.phtml @@ -1,16 +1,25 @@ - + - + + $("[data-block=\"minicart\"]").on("dropdowndialogopen", function ( e ) { + taggrsAjaxEvent('viewcart', () => {}, 1); + }); +}); + +JS; +?> + +renderTag('script', ['type' => 'text/javascript'], $script, false); ?> diff --git a/view/frontend/templates/checkout-js.phtml b/view/frontend/templates/checkout-js.phtml index d4ae06c..679fbac 100644 --- a/view/frontend/templates/checkout-js.phtml +++ b/view/frontend/templates/checkout-js.phtml @@ -1,12 +1,22 @@ - + }); + +JS; +?> + +renderTag('script', ['type' => 'text/javascript'], $script, false); ?> diff --git a/view/frontend/templates/data-layer.phtml b/view/frontend/templates/data-layer.phtml index faba7cd..869519b 100644 --- a/view/frontend/templates/data-layer.phtml +++ b/view/frontend/templates/data-layer.phtml @@ -1,13 +1,21 @@ -getDataLayer(); +$jsonDatalayer = /* @noEscape */ json_encode($block->getDataLayer()); ?> - + + { + const dataLayer = $jsonDatalayer; + taggrsPush(dataLayer, true); + }); +})(); + +JS; +?> + +renderTag('script', ['type' => 'text/javascript'], $script, false); ?> diff --git a/view/frontend/templates/gtag.phtml b/view/frontend/templates/gtag.phtml index 993451a..0ab7a3a 100644 --- a/view/frontend/templates/gtag.phtml +++ b/view/frontend/templates/gtag.phtml @@ -1,128 +1,146 @@ + +getGtmCode() ) ) { + $url = $escaper->escapeJs( $escaper->escapeUrl( $block->getGtmUrl() ) ); + $gtmCode = $escaper->escapeHtml( $block->getGtmCode() ); + + $gtmTagScript = <<getGtmUrl(); -$gtmCode = $block->getGtmCode(); + echo /* @noEscape */ $secureRenderer->renderTag( 'script', [ 'type' => 'text/javascript' ], $gtmTagScript, false ); +} ?> -getGtmCode())): ?> - - - + }) + .then(data => { + taggrsPush(data, false); + if (typeof callback === 'function') { + callback(); + } + }) + .catch(error => { + console.log(error); + }); +} +JS; + +echo /* @noEscape */ $secureRenderer->renderTag( 'script', [ 'type' => 'text/javascript' ], $helpersScript, false ); +?> diff --git a/view/frontend/templates/noscript.phtml b/view/frontend/templates/noscript.phtml index cd8bef7..68dc3d6 100644 --- a/view/frontend/templates/noscript.phtml +++ b/view/frontend/templates/noscript.phtml @@ -2,8 +2,8 @@ /** @var \Taggrs\DataLayer\Block\NoScript $block */ /** @var \Magento\Framework\Escaper $escaper */ -$url = $block->getGtmUrl(); ; -$gtmCode = $block->getGtmCode(); ; +$url = $block->getGtmUrl(); +$gtmCode = $block->getGtmCode(); ?>