{% with settings.wagtail_analytics.AnalyticsSettings as settings %}
{% if settings.plausible_enabled %}
<script defer data-domain="{{ settings.site.hostname }}" src="{{ settings.plausible_base_url }}/js/script.js"></script>
{% endif %}
{% if settings.google_tag_manager_enabled and settings.google_tag_manager_container_id %}
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{{ settings.google_tag_manager_container_id }}');</script>
<!-- End Google Tag Manager -->
{% endif %}
{% if settings.google_analytics_enabled and settings.google_analytics_property_id %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ settings.google_analytics_property_id }}"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', '{{ settings.google_analytics_property_id }}');
</script>
{% endif %}
{% if settings.google_site_verification %}
<meta name="google-site-verification" content="{{ settings.google_site_verification }}" />
{% endif %}
{% endwith %}
