{% block beforeScriptTag %}{{ blocks.beforeScriptTag|raw }}{% endblock %}

<script>
    {% block beforeScript %}{{ blocks.beforeScript|raw }}{% endblock %}

    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    {% block beforeInit %}{{ blocks.beforeInit|raw }}{% endblock %}

    {% block trackInit %}
    {% if universalConfiguration %}
    ga('create', '{{ trackId }}', {{ universalConfiguration|raw }});
    {% else %}
    ga('create', '{{ trackId }}');
    {% endif %}

    ga('set', 'anonymizeIp', true);
    {% endblock %}

    {% block beforeTrack %}{{ blocks.beforeTrack|raw }}{% endblock %}

    {% block track %}
    if (typeof _gaqPageView != "undefined"){
        ga('send', 'pageview', _gaqPageView);
    } else {
        {% if defaultPath %}
        ga('send', 'pageview', '{{ defaultPath }}');
        {% else %}
        ga('send', 'pageview');
        {% endif %}
    }
    {% endblock %}

    {% block afterTrack %}{{ blocks.afterTrack|raw }}{% endblock %}
    {% block afterScript %}{{ blocks.afterScript|raw }}{% endblock %}
</script>

{% block afterScriptTag %}{{ blocks.afterScriptTag|raw }}{% endblock %}
