{% if particle.ua.code %}

    {% scripts %}
      <script async src="https://www.googletagmanager.com/gtag/js?id={{ particle.ua.code }}"></script>
    {% endscripts %}

    {% set script %}
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', '{{ particle.ua.code }}');

      {% if particle.ua.anonym %}
        gtag('set', { 'anonymize_ip': true });
      {% endif %}
    {% endset %}

    {% do gantry.document.addInlineScript(script, 0) %}
{% endif %}
