Skip to content

Commit

Permalink
feat: add google analytics tags
Browse files Browse the repository at this point in the history
  • Loading branch information
tieandrews committed Dec 30, 2023
1 parent 1b969cf commit b65e9ec
Showing 1 changed file with 30 additions and 27 deletions.
57 changes: 30 additions & 27 deletions src/dashgpt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

load_dotenv(find_dotenv())

GOOGLE_ANALYTICS_TAG = os.getenv("GOOGLE_ANALYTICS_TAG", "")

logger = get_logger(__name__)

flask_server = Flask(__name__)
Expand All @@ -28,35 +30,36 @@
suppress_callback_exceptions=True,
)

# dash_app.index_string = """
# <!DOCTYPE html>
# <html>
# <head>
# <!-- Google tag (gtag.js) -->
# <script async src="https://www.googletagmanager.com/gtag/js?id=G-Z0JFX6WWM6"></script>
# <script>
# window.dataLayer = window.dataLayer || [];
# function gtag(){dataLayer.push(arguments);}
# gtag('js', new Date());
if GOOGLE_ANALYTICS_TAG != "":
dash_app.index_string = ("""
<!DOCTYPE html>
<html>
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=""" + GOOGLE_ANALYTICS_TAG + """"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
# gtag('config', 'G-Z0JFX6WWM6');
# </script>
gtag('config', '""" + GOOGLE_ANALYTICS_TAG + """');
</script>
# {%metas%}
# <title>{%title%}</title>
# {%favicon%}
# {%css%}
# </head>
# <body>
# {%app_entry%}
# <footer>
# {%config%}
# {%scripts%}
# {%renderer%}
# </footer>
# </body>
# </html>
# """
{%metas%}
<title>{%title%}</title>
{%favicon%}
{%css%}
</head>
<body>
{%app_entry%}
<footer>
{%config%}
{%scripts%}
{%renderer%}
</footer>
</body>
</html>
""")

dash_app.layout = html.Div(
children=[dash.page_container],
Expand Down

0 comments on commit b65e9ec

Please sign in to comment.