add analytics support

main
Dominik Madarász 2023-01-12 17:04:19 +00:00
parent cf1dd7973e
commit 74b64c5a63
3 changed files with 13 additions and 0 deletions

View File

@ -110,6 +110,7 @@ class Config(pydantic.BaseModel):
custom_footer: str | None = None custom_footer: str | None = None
emoji: str | None = None emoji: str | None = None
also_known_as: str | None = None also_known_as: str | None = None
ga_analytics: str | None = None
hides_followers: bool = False hides_followers: bool = False
hides_following: bool = False hides_following: bool = False

View File

@ -434,6 +434,7 @@ _templates.env.globals["JS_HASH"] = config.JS_HASH
_templates.env.globals["CSS_HASH"] = config.CSS_HASH _templates.env.globals["CSS_HASH"] = config.CSS_HASH
_templates.env.globals["BASE_URL"] = config.BASE_URL _templates.env.globals["BASE_URL"] = config.BASE_URL
_templates.env.globals["TAGS"] = config.CONFIG.tags _templates.env.globals["TAGS"] = config.CONFIG.tags
_templates.env.globals["GA_ANALYTICS"] = config.CONFIG.ga_analytics
_templates.env.globals["HIDES_FOLLOWERS"] = config.HIDES_FOLLOWERS _templates.env.globals["HIDES_FOLLOWERS"] = config.HIDES_FOLLOWERS
_templates.env.globals["HIDES_FOLLOWING"] = config.HIDES_FOLLOWING _templates.env.globals["HIDES_FOLLOWING"] = config.HIDES_FOLLOWING
_templates.env.globals["NAVBAR_ITEMS"] = config.NavBarItems _templates.env.globals["NAVBAR_ITEMS"] = config.NavBarItems

View File

@ -1,6 +1,17 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html lang="en"> <html lang="en">
<head> <head>
{% if GA_ANALYTICS %}
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ GA_ANALYTICS }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ GA_ANALYTICS }}');
</script>
{% endif %}
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge"> <meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">