custom/plugins/DIScoGA4/src/Resources/views/storefront/ga4/meta-extra-information.html.twig line 1

Open in your IDE?
  1. {% block disco_meta_extra_information %}
  2.     {% block disco_meta_extra_information_custom_url %}
  3.         {% if config('DIScoGA4.config.customUrl') %}
  4.             <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  5.                     type="text/javascript">
  6.                 window.ga4CustomUrl = '{{ config('DIScoGA4.config.customUrl')|raw }}';
  7.             </script>
  8.         {% else %}
  9.             <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  10.                     type="text/javascript">
  11.                 window.ga4CustomUrl = '';
  12.             </script>
  13.         {% endif %}
  14.     {% endblock %}
  15.     {% block disco_meta_extra_information_checkout_extra %}
  16.         {% block disco_meta_extra_information_checkout_extra_shipping_method %}
  17.             {% if page.order.deliveries.first.shippingMethod is defined %}
  18.                 <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  19.                         type="text/javascript">
  20.                     window.ga4ShippingMethod = '{{ page.order.deliveries.first.shippingMethod.translated.name }}';
  21.                 </script>
  22.             {% endif %}
  23.         {% endblock %}
  24.         {% block disco_meta_extra_information_checkout_extra_payment_method %}
  25.             {% if page.order.transactions.last.paymentMethod is defined %}
  26.                 <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  27.                         type="text/javascript">
  28.                     window.ga4PaymentMethod = '{{ page.order.transactions.last.paymentMethod.translated.name }}';
  29.                 </script>
  30.             {% endif %}
  31.         {% endblock %}
  32.         {% block disco_meta_extra_information_checkout_extra_order_number %}
  33.             {% if page.order.orderNumber is defined %}
  34.                 <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  35.                         type="text/javascript">
  36.                     window.ga4OrderNumber = '{{ page.order.orderNumber }}';
  37.                 </script>
  38.             {% endif %}
  39.         {% endblock %}
  40.     {% endblock %}
  41.     {% block disco_meta_extra_information_main %}
  42.         {% block disco_meta_extra_information_searchterm %}
  43.             {% if page.searchTerm %}
  44.                 <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  45.                         type="text/javascript">
  46.                     window.searchTerm = '{{ page.searchTerm }}';
  47.                 </script>
  48.             {% endif %}
  49.         {% endblock %}
  50.         {% block disco_meta_extra_information_searchResult %}
  51.             {% if page.listing.total %}
  52.                 <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  53.                         type="text/javascript">
  54.                     window.searchResult = '{{ page.listing.total }}';
  55.                 </script>
  56.             {% endif %}
  57.         {% endblock %}
  58.         {% block disco_meta_extra_information_config %}
  59.             {% block disco_meta_extra_information_config_initialisation %}
  60.                 <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  61.                         type="text/javascript">
  62.                     window.ga4RemarketingEnabled = false;
  63.                     window.googleAnalyticsEnabled = false;
  64.                     window.googleAdsEnabled = false;
  65.                     window.ga4AdvancedAdsEnabled = false;
  66.                     window.ga4Enabled = false;
  67.                     window.googleTagEnabled = false;
  68.                     {% if config('DIScoGA4.config.cookieConfig') %}
  69.                     window.ga4CookieConfig = '{{ config('DIScoGA4.config.cookieConfig') }}';
  70.                     {% else %}
  71.                     window.ga4CookieConfig = "standardCookies";
  72.                     {% endif %}
  73.                     {% if config('DIScoGA4.config.ga4cookieListener') %}
  74.                     window.ga4cookieListener = true;
  75.                     {% else %}
  76.                     window.ga4cookieListener = false;
  77.                     {% endif %}
  78.                     {% if config('DIScoGA4.config.generateLeadValue') %}
  79.                     window.generateLeadValue = '{{ config('DIScoGA4.config.generateLeadValue') }}';
  80.                     {% else %}
  81.                     window.generateLeadValue = 0.0;
  82.                     {% endif %}
  83.                     window.ga4Currency = '{{ context.currency.translated.shortName }}';
  84.                     {% if config('DIScoGA4.config.transationIdMethod') and config('DIScoGA4.config.transationIdMethod') == "trueOrderId" %}
  85.                     window.transationIdMethod = "trueOrderId";
  86.                     {% else %}
  87.                     window.transationIdMethod = "hashedOrderId";
  88.                     {% endif %}
  89.                     {% if config('DIScoGA4.config.phoneNumberMethod') and config('DIScoGA4.config.phoneNumberMethod') == "truePhoneNumber" %}
  90.                     window.phoneNumberMethod = "truePhoneNumber";
  91.                     {% else %}
  92.                     window.phoneNumberMethod = "hashedPhoneNumber";
  93.                     {% endif %}
  94.                 </script>
  95.             {% endblock %}
  96.             {% block disco_meta_extra_information_config_activation %}
  97.                 {% if config('DIScoGA4.config.googleTagEnabled') and config('DIScoGA4.config.googleTagId') %}
  98.                     <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  99.                             type="text/javascript">
  100.                         window.ga4TagId = '{{ config('DIScoGA4.config.googleTagId')|raw }}';
  101.                         window.dataLayer = window.dataLayer || [];
  102.                         window.googleTagEnabled = true;
  103.                         window.ga4Enabled = true;
  104.                         window.ga4controllerName = '{{ controllerName|lower }}';
  105.                         window.ga4controllerAction = '{{ controllerAction|lower }}';
  106.                         window.ga4activeNavigationId = '{{ page.header.navigation.active.id }}';
  107.                         window.ga4activeNavigationName = '{{ page.header.navigation.active.name }}';
  108.                         window.ga4affiliation = '{{ context.salesChannel.name }}';
  109.                         window.ga4salesChannelName = '{{ context.salesChannel.name }}';
  110.                         window.ga4salesChannelId = '{{ context.salesChannel.id }}';
  111.                         {% if config('DIScoGA4.config.enableUserId') %}
  112.                         window.ga4enableUserId = true;
  113.                         {% else %}
  114.                         window.ga4enableUserId = false;
  115.                         {% endif %}
  116.                         {% if config('DIScoGA4.config.uvpPriceAsCoupon') %}
  117.                         window.ga4upCoupon = true;
  118.                         {% else %}
  119.                         window.ga4upCoupon = false;
  120.                         {% endif %}
  121.                         {% if config('DIScoGA4.config.graduatedPriceAsCoupon') %}
  122.                         window.ga4gpCoupon = true;
  123.                         {% else %}
  124.                         window.ga4gpCoupon = false;
  125.                         {% endif %}
  126.                     </script>
  127.                 {% endif %}
  128.             {% endblock %}
  129.             {% block disco_meta_extra_information_config_google_analytics %}
  130.                 {% if config('DIScoGA4.config.googleAnalyticsEnabled') %}
  131.                     <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  132.                             type="text/javascript">
  133.                         window.googleAnalyticsEnabled = true;
  134.                     </script>
  135.                 {% endif %}
  136.             {% endblock %}
  137.         {% endblock %}
  138.         {% block disco_meta_extra_information_usertracking %}
  139.             {% if context.customer is not null and not context.customer.guest ? 1 : 0 %}
  140.                 <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  141.                         type="text/javascript">
  142.                     window.ga4UserLoggedIn = true;
  143.                 </script>
  144.                 {% if config('DIScoGA4.config.enableUserId') %}
  145.                     <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  146.                             type="text/javascript">
  147.                         window.ga4UserId = '{{ context.customer.id }}';
  148.                     </script>
  149.                 {% endif %}
  150.             {% else %}
  151.                 <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  152.                         type="text/javascript">
  153.                     window.ga4UserLoggedIn = false;
  154.                     if (localStorage.getItem("loginSent")) localStorage.removeItem("loginSent")
  155.                 </script>
  156.             {% endif %}
  157.             {% if config('DIScoGA4.config.googleAdsEnabled') %}
  158.                 <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  159.                         type="text/javascript">
  160.                     {% if config('DIScoGA4.config.enableRemarketing') %}
  161.                     window.ga4RemarketingEnabled = true;
  162.                     {% else %}
  163.                     window.ga4RemarketingEnabled = false;
  164.                     {% endif %}
  165.                     window.googleAdsEnabled = true;
  166.                     {% if config('DIScoGA4.config.enableAdsAdvanced') %}
  167.                     window.ga4AdvancedAdsEnabled = true;
  168.                     {% else %}
  169.                     window.ga4AdvancedAdsEnabled = false;
  170.                     {% endif %}
  171.                     {% if config('DIScoGA4.config.adsValueNetto') and config('DIScoGA4.config.adsValueNetto') == "netto" %}
  172.                     window.adsValueNetto = true;
  173.                     {% else %}
  174.                     window.adsValueNetto = false;
  175.                     {% endif %}
  176.                     {% if config('DIScoGA4.config.transationIdMethod') and config('DIScoGA4.config.transationIdMethod') == "trueOrderId" %}
  177.                     window.transationIdMethod = "trueOrderId";
  178.                     {% else %}
  179.                     window.transationIdMethod = "hashedOrderId";
  180.                     {% endif %}
  181.                 </script>
  182.                 {% if context.customer is not null %}
  183.                     <span class='d-none ga4-hidden-ads-information'
  184.                           data-feedcountry='{{ config('DIScoGA4.config.feedCountry') }}'
  185.                           data-feedlangage='{{ config('DIScoGA4.config.feedLanguage') }}' {% if config('DIScoGA4.config.enableAdsAdvanced') %} data-useremail='{{ context.customer.email }}' data-phone='{{ context.customer.activeBillingAddress.phoneNumber }}' data-firstname='{{ context.customer.activeBillingAddress.firstName }}' data-lastname='{{ context.customer.activeBillingAddress.lastName }}' data-street='{{ context.customer.activeBillingAddress.street }}' data-city='{{ context.customer.activeBillingAddress.city }}' data-region='{{ context.customer.activeBillingAddress.countryState.name }}' data-zip='{{ context.customer.activeBillingAddress.zipcode }}' data-land='{{ context.customer.activeBillingAddress.country.name }}' {% endif %}></span>
  186.                 {% endif %}
  187.             {% endif %}
  188.         {% endblock %}
  189.         {% block disco_meta_extra_information_specialcase %}
  190.             <script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
  191.                     type="text/javascript">
  192.                 if (window.googleAdsEnabled !== true && window.googleAnalyticsEnabled !== true) {
  193.                     window.ga4Enabled = false;
  194.                 }
  195.             </script>
  196.         {% endblock %}
  197.     {% endblock %}
  198.     {% block disco_meta_extra_information_extensions %}
  199.         {% sw_include '@Storefront/storefront/ga4/ga4-products-extensions.html.twig' %}
  200.     {% endblock %}
  201. {% block disco_hidden_line_items_information %}
  202.     {% if page.cart %}
  203.     {% set discocart= page.cart %}
  204.     {% set discolineItems = page.cart.lineItems %}
  205.     <div class="d-none discoga4-header-hidden-line-items-information"
  206.          data-currency="{{ context.currency.translated.shortName }}"
  207.          data-shipping="{{ discocart.deliveries.shippingCosts.sum().totalPrice }}"
  208.          data-value="{{ discocart.price.totalPrice }}"
  209.          data-tax="{{ discocart.price.calculatedTaxes.amount }}"
  210.     >
  211.         {% endif %}
  212.         {% if page.order %}
  213.         {% set discocart= page.order %}
  214.         {% set discolineItems = page.order.lineItems %}
  215.         <div class="d-none discoga4-header-hidden-line-items-information"
  216.              data-currency="{{ context.currency.translated.shortName }}"
  217.              data-shipping="{{ discocart.shippingTotal }}"
  218.              data-value="{{ discocart.price.totalPrice }}"
  219.              data-tax="{{ discocart.price.calculatedTaxes.amount }}"
  220.         >
  221.             {% endif %}
  222.             {% if discocart %}
  223.             {% for lineItem in discolineItems %}
  224.                 {% if lineItem.priceDefinition.price %}
  225.                     {% set gaPrice = lineItem.priceDefinition.price %}
  226.                 {% else %}
  227.                     {% set gaPrice = lineItem.price.totalPrice %}
  228.                 {% endif %}
  229.                 {% block disco_hidden_line_item_information %}
  230.                     <span class="hidden-line-item"
  231.                           data-id="{{ lineItem.id }}"
  232.                           data-name="{{ lineItem.label }}"
  233.                           data-type="{{ lineItem.type }}"
  234.                           data-sku="{{ lineItem.payload.productNumber }}"
  235.                           data-quantity="{{ lineItem.quantity }}"
  236.                           data-price="{{ gaPrice }}">
  237.                 </span>
  238.                 {% endblock %}
  239.             {% endfor %}
  240.         </div>
  241.         {% endif %}
  242.         {% endblock %}
  243. {% endblock %}