vendor/shopware/storefront/Resources/views/storefront/component/analytics.html.twig line 1

Open in your IDE?
  1. {% block component_head_analytics %}
  2.     {% block component_head_analytics_gtag %}
  3.         {% if context.salesChannel.analytics and context.salesChannel.analytics.isActive() %}
  4.             {% set trackingId = context.salesChannel.analytics.getTrackingId() %}
  5.             <script>
  6.                 {% block component_head_analytics_gtag_config %}
  7.                     window.gtagActive = true;
  8.                     window.gtagURL = 'https://www.googletagmanager.com/gtag/js?id={{ trackingId }}'
  9.                     window.controllerName = '{{ controllerName|lower }}';
  10.                     window.actionName = '{{ controllerAction|lower }}';
  11.                     window.trackOrders = '{{ context.salesChannel.analytics.isTrackOrders() }}';
  12.                     window.gtagTrackingId = '{{ trackingId }}';
  13.                     window.dataLayer = window.dataLayer || [];
  14.                     window.gtagConfig = {
  15.                         'anonymize_ip': '{{ context.salesChannel.analytics.isAnonymizeIp() }}',
  16.                         'cookie_domain': 'none',
  17.                         'cookie_prefix': '_swag_ga',
  18.                     };
  19.                     function gtag() { dataLayer.push(arguments); }
  20.                 {% endblock %}
  21.             </script>
  22.             {# @deprecated tag:v6.5.0 - the gtag callback and #sw-google-tag-manager-init will be removed without replacement, since the logic moved into the google analytics plugin #}
  23.             {% if not feature('v6.5.0.0') %}
  24.                 <script id="sw-google-tag-manager-init" type="javascript/blocked">
  25.                     {% block component_head_analytics_tag_config %}
  26.                         window.gtagCallback = function gtagCallbackFunction() {}
  27.                     {% endblock %}
  28.                 </script>
  29.             {% endif %}
  30.         {% endif %}
  31.     {% endblock %}
  32. {% endblock %}