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

Open in your IDE?
  1. {% block component_head_analytics %}
  2.     {% if context.salesChannel.analytics and context.salesChannel.analytics.isActive() %}
  3.         {% set trackingId = context.salesChannel.analytics.getTrackingId() %}
  4.         <script>
  5.             window.gtagActive = true;
  6.             window.gtagURL = 'https://www.googletagmanager.com/gtag/js?id={{ trackingId }}'
  7.         </script>
  8.         <script id="sw-google-tag-manager-init" type="javascript/blocked">
  9.             window.controllerName = '{{ controllerName|lower }}';
  10.             window.actionName = '{{ controllerAction|lower }}';
  11.             window.dataLayer = window.dataLayer || [];
  12.             window.trackOrders = '{{ context.salesChannel.analytics.isTrackOrders() }}';
  13.             function gtag() { dataLayer.push(arguments); }
  14.             {% block component_head_analytics_tag_config %}
  15.             window.gtagCallback = function gtagCallbackFunction() {
  16.                 gtag('js', new Date());
  17.                 gtag('config', '{{ trackingId }}', {
  18.                     'anonymize_ip': '{{ context.salesChannel.analytics.isAnonymizeIp() }}',
  19.                     'cookie_domain': 'none',
  20.                     'cookie_prefix': '_swag_ga',
  21.                 });
  22.             };
  23.             {% endblock %}
  24.         </script>
  25.     {% endif %}
  26. {% endblock %}