custom/plugins/WbmTagManagerAnalytics/src/Resources/views/storefront/layout/meta.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/layout/meta.html.twig' %}
  2. {% block layout_head_meta_tags_charset %}
  3.     {{ parent() }}
  4.     <!-- WbmTagManagerAnalytics Head Snippet Start -->
  5.     {% block wbm_layout_head_tag_manager_data_layer_push %}
  6.         <script id="wbmTagMangerDefine" {{ wbmTagManagerConfig.dataLayerScriptTagAttributes|raw }}>{% verbatim %}
  7.             let gtmIsTrackingProductClicks = Boolean({% endverbatim %}{{ wbmTagManagerConfig.isTrackingProductClicks|raw }}{% verbatim %}),
  8.                 gtmIsTrackingAddToWishlistClicks = Boolean({% endverbatim %}{{ wbmTagManagerConfig.isTrackingAddToWishlistClicks|raw }}{% verbatim %}),
  9.                 gtmContainerId = '{% endverbatim %}{{ wbmTagManagerConfig.gtmContainerId|raw }}{% verbatim %}',
  10.                 hasSWConsentSupport = Boolean(Number({% endverbatim %}{{ wbmTagManagerConfig.hasSWConsentSupport }}{% verbatim %}));
  11.             window.wbmScriptIsSet = false;
  12.             window.dataLayer = window.dataLayer || [];
  13.             window.dataLayer.push({% endverbatim %}{{ dataLayerUser|raw }}{% verbatim %});{% endverbatim %}
  14.         </script>
  15.         {% if dataLayer %}<script id="wbmTagMangerDataLayer" {{ wbmTagManagerConfig.dataLayerScriptTagAttributes|raw }}>{% verbatim %}
  16.             window.dataLayer.push({ ecommerce: null });
  17.             window.dataLayer.push({% endverbatim %}{{ dataLayer|raw }}{% verbatim %});
  18.             {% endverbatim %}{% if onEvent %}{% verbatim %}
  19.             var onEventDataLayer = JSON.parse('{% endverbatim %}{{ onEvent|raw }}{% verbatim %}');
  20.             {% endverbatim %}{% endif %}
  21.         </script>{% endif %}
  22.     {% endblock %}
  23.     {% block wbm_layout_head_tag_manager_snippet %}
  24.         {% if wbmTagManagerConfig.gtmContainerId %}
  25.         <script id="wbmTagManger" {{ wbmTagManagerConfig.scriptTagAttributes|raw }}>{% verbatim %}
  26.             function getCookie(name) {
  27.                 var cookieMatch = document.cookie.match(name + '=(.*?)(;|$)');
  28.                 return cookieMatch && decodeURI(cookieMatch[1]);
  29.             }
  30.             var gtmCookieSet = getCookie('{% endverbatim %}{{ wbmTagManagerConfig.wbmCookieEnabledName }}{% verbatim %}');
  31.             {% endverbatim %}{% if wbmTagManagerConfig.gtmFunctionOverwrite is empty %}{% verbatim %}
  32.             var googleTag = function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl+'{% endverbatim %}{{ wbmTagManagerConfig.extendedUrlParameter|trim|raw }}{% verbatim %}';f.parentNode.insertBefore(j,f);};
  33.             {% endverbatim %}{% else %}{% verbatim %}
  34.             var googleTag = {% endverbatim %}{{ wbmTagManagerConfig.gtmFunctionOverwrite|replace({"\n": "", "\r": "", "\t": ""})|raw }}{% verbatim %}
  35.             {% endverbatim %}{% endif %}{% verbatim %}
  36.             if (hasSWConsentSupport && gtmCookieSet === null) {
  37.                 window.wbmGoogleTagmanagerId = gtmContainerId;
  38.                 window.wbmScriptIsSet = false;
  39.                 window.googleTag = googleTag;
  40.             } else {
  41.                 window.wbmScriptIsSet = true;
  42.                 googleTag(window, document, 'script', 'dataLayer', gtmContainerId);
  43.                 googleTag = null;
  44.             }{% endverbatim %}
  45.         </script><!-- WbmTagManagerAnalytics Head Snippet End -->{% endif %}
  46.     {% endblock %}
  47. {% endblock %}