diff --git a/material/base.html b/material/base.html index 75b7e0e18..50e7f4c7c 100644 --- a/material/base.html +++ b/material/base.html @@ -71,9 +71,7 @@ {% endfor %} {% block analytics %} - {% if config.google_analytics %} - {% include "partials/integrations/analytics.html" %} - {% endif %} + {% include "partials/integrations/analytics.html" %} {% endblock %} {% block extrahead %}{% endblock %} diff --git a/material/partials/integrations/analytics.html b/material/partials/integrations/analytics.html index 5328ce436..13f7608ef 100644 --- a/material/partials/integrations/analytics.html +++ b/material/partials/integrations/analytics.html @@ -1,6 +1,10 @@ {#- This file was automatically generated - do not edit -#} -{% set analytics = config.google_analytics %} - - +{% if config.google_analytics %} + {% set provider = "google" %} +{% endif %} +{% if config.extra.analytics %} + {% set provider = config.extra.analytics.provider %} +{% endif %} +{% include "partials/integrations/analytics/" ~ provider ~ ".html" %} diff --git a/material/partials/integrations/analytics/google.html b/material/partials/integrations/analytics/google.html new file mode 100644 index 000000000..ed5e6bcfd --- /dev/null +++ b/material/partials/integrations/analytics/google.html @@ -0,0 +1,16 @@ +{#- + This file was automatically generated - do not edit +-#} +{% if config.google_analytics %} + {% set property = config.google_analytics[0] %} +{% endif %} +{% if config.extra.analytics %} + {% set property = config.extra.analytics.property | d("", true) %} +{% endif %} +{% if property.startswith("G-") %} + + +{% elif property.startswith("UA-") %} + + +{% endif %} diff --git a/mkdocs.yml b/mkdocs.yml index 934e1aaa4..0cae97d87 100755 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -98,6 +98,9 @@ plugins: # Customization extra: + analytics: + provider: google + property: !!python/object/apply:os.getenv ["GOOGLE_ANALYTICS_KEY"] social: - icon: fontawesome/brands/github link: https://github.com/squidfunk @@ -202,8 +205,3 @@ nav: - Getting started: - Installation: insiders/getting-started.md - Changelog: insiders/changelog.md - -# Google Analytics -google_analytics: - - !!python/object/apply:os.getenv ["GOOGLE_ANALYTICS_KEY"] - - auto diff --git a/src/base.html b/src/base.html index 90399dc81..6ed01ce90 100644 --- a/src/base.html +++ b/src/base.html @@ -143,9 +143,7 @@ {% block analytics %} - {% if config.google_analytics %} - {% include "partials/integrations/analytics.html" %} - {% endif %} + {% include "partials/integrations/analytics.html" %} {% endblock %} diff --git a/src/partials/integrations/analytics.html b/src/partials/integrations/analytics.html index f81d59cfe..b4c3d0bf0 100644 --- a/src/partials/integrations/analytics.html +++ b/src/partials/integrations/analytics.html @@ -20,36 +20,15 @@ IN THE SOFTWARE. --> - -{% set analytics = config.google_analytics %} - - + +{% include "partials/integrations/analytics/" ~ provider ~ ".html" %} diff --git a/src/partials/integrations/analytics/google.html b/src/partials/integrations/analytics/google.html new file mode 100644 index 000000000..632558e4b --- /dev/null +++ b/src/partials/integrations/analytics/google.html @@ -0,0 +1,93 @@ + + + +{% if config.google_analytics %} + {% set property = config.google_analytics[0] %} +{% endif %} + + +{% if config.extra.analytics %} + {% set property = config.extra.analytics.property | d("", true) %} +{% endif %} + + +{% if property.startswith("G-") %} + + + + +{% elif property.startswith("UA-") %} + + +{% endif %} + +