【发布时间】:2023-01-26 01:45:13
【问题描述】:
我想在 Google Analytics 中跟踪我使用 Streamlit 构建的 UI。 根据 Google Analytics,需要将以下内容添加到 HTML 的 <head> 部分。
<script async src="https://www.googletagmanager.com/gtag/js?id=G-**********"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-**********');
</script>
由于我的代码架构中没有任何 html 文件,因此我在主 .py 文件中包含了以下 Streamlit 行:
google_analytics_js = '[previous_html_code]'
st.components.v1.html(google_analytics_js)
不幸的是,该网站未被跟踪。对此的任何帮助将不胜感激。
【问题讨论】:
-
谢谢。我看到是的,但该页面中没有讨论过的解决方案适用于我的情况
标签: python html google-analytics fastapi streamlit