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 async src="https://www.googletagmanager.com/gtag/js?id={{ trackingId }}"></script>
  5.         <script>
  6.             window.gtagActive = true;
  7.             window.controllerName = '{{ controllerName|lower }}';
  8.             window.actionName = '{{ controllerAction|lower }}';
  9.             window.dataLayer = window.dataLayer || [];
  10.             window.trackOrders = '{{ context.salesChannel.analytics.isTrackOrders() }}';
  11.             function gtag() { dataLayer.push(arguments); }
  12.             window.gtagCallback = () => {
  13.                 gtag('js', new Date());
  14.                 gtag('config', '{{ trackingId }}', {
  15.                     'cookie_domain': 'none',
  16.                     'cookie_prefix': '_swag_ga',
  17.                 });
  18.             };
  19.         </script>
  20.     {% endif %}
  21. {% endblock %}