<script type="text/javascript">
    var piwik = {};
    piwik.token_auth = "{{ token_auth }}";
    piwik.piwik_url = "{{ piwikUrl }}";
    piwik.cacheBuster = "{{ cacheBuster }}";
    {% if timezoneOffset is defined %}piwik.timezoneOffset = {{ timezoneOffset }};{% endif %}

    piwik.numbers = {
        patternNumber: "{{ 'Intl_NumberFormatNumber'|translate }}",
        patternPercent: "{{ 'Intl_NumberFormatPercent'|translate }}",
        patternCurrency: "{{ 'Intl_NumberFormatCurrency'|translate }}",
        symbolPlus: "{{ 'Intl_NumberSymbolPlus'|translate }}",
        symbolMinus: "{{ 'Intl_NumberSymbolMinus'|translate }}",
        symbolPercent: "{{ 'Intl_NumberSymbolPercent'|translate }}",
        symbolGroup: "{{ 'Intl_NumberSymbolGroup'|translate }}",
        symbolDecimal: "{{ 'Intl_NumberSymbolDecimal'|translate }}"
    };

    piwik.relativePluginWebDirs = {{ relativePluginWebDirs|json_encode|raw }}

    {% if userLogin %}piwik.userLogin = "{{ userLogin|e('js')}}";{% endif %}

    {% if idSite is defined %}piwik.idSite = "{{ idSite }}";{% endif %}

    {% if siteName is defined %}
    // NOTE: siteName is currently considered deprecated, use piwik.currentSiteName instead, which will not contain HTML entities
    piwik.siteName = "{{ siteName|e('js') }}";
    {% if siteNameDecoded is defined %} // just to be safe
    piwik.currentSiteName = {{ siteNameDecoded|json_encode|raw }};{% endif %}
    {% endif %}

    {% if siteMainUrl is defined %}piwik.siteMainUrl = "{{ siteMainUrl|e('js') }}";{% endif %}

    {% if period is defined %}piwik.period = "{{ period }}";{% endif %}

{# piwik.currentDateString should not be used other than by the calendar Javascript
            (it is not set to the expected value when period=range)
        Use broadcast.getValueFromUrl('date') instead
#}
    piwik.currentDateString = "{{ date|default(endDate|default('')) }}";
{% if startDate is defined %}
    piwik.startDateString = "{{ startDate }}";
    piwik.endDateString = "{{ endDate }}";
    piwik.minDateYear = {{ minDateYear }};
    piwik.minDateMonth = parseInt("{{ minDateMonth }}", 10);
    piwik.minDateDay = parseInt("{{ minDateDay }}", 10);
    piwik.maxDateYear = {{ maxDateYear }};
    piwik.maxDateMonth = parseInt("{{ maxDateMonth }}", 10);
    piwik.maxDateDay = parseInt("{{ maxDateDay }}", 10);
{% endif %}
    {% if language is defined %}piwik.language = "{{ language }}";{% endif %}

    piwik.hasSuperUserAccess = {{ hasSuperUserAccess|default(0)|e('js')}};
    piwik.userCapabilities = {{ userCapabilities|default([])|json_encode|raw }};
    piwik.config = {};
{% if clientSideConfig is defined %}
    piwik.config = {{ clientSideConfig|json_encode|raw }};
{% endif %}
    piwik.shouldPropagateTokenAuth = {{ shouldPropagateTokenAuth|json_encode|raw }};
    {{ postEvent("Template.jsGlobalVariables") }}
</script>

