Spaces:
Sleeping
Sleeping
Add GTM scripts and update Streamlit config
Browse filesImported `streamlit.components.v1` for custom HTML components. Added Google Tag Manager scripts to the `main` function using `components.html`. Set `initial_sidebar_state` to `None` and removed related comments. Cleaned up CSS to hide the sidebar and adjust element visibility.
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
from battlewords.ui import run_app, _init_session
|
| 4 |
|
|
@@ -13,11 +14,25 @@ def main(opened=False):
|
|
| 13 |
st.set_page_config(
|
| 14 |
page_title="Battlewords",
|
| 15 |
layout="wide",
|
| 16 |
-
#initial_sidebar_state="expanded" if opened else "collapsed",
|
| 17 |
initial_sidebar_state=None,
|
| 18 |
page_icon="app/static/favicon.ico"
|
| 19 |
)
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
st.markdown(
|
| 22 |
"""<style>
|
| 23 |
div[data-testid='stSidebar'] { display: none !important; }
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import streamlit.components.v1 as components
|
| 3 |
|
| 4 |
from battlewords.ui import run_app, _init_session
|
| 5 |
|
|
|
|
| 14 |
st.set_page_config(
|
| 15 |
page_title="Battlewords",
|
| 16 |
layout="wide",
|
|
|
|
| 17 |
initial_sidebar_state=None,
|
| 18 |
page_icon="app/static/favicon.ico"
|
| 19 |
)
|
| 20 |
|
| 21 |
+
components.html('''
|
| 22 |
+
<!-- Google Tag Manager -->
|
| 23 |
+
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
| 24 |
+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
| 25 |
+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
| 26 |
+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
| 27 |
+
})(window,document,'script','dataLayer','GTM-MKBM5JQ6');</script>
|
| 28 |
+
''', height=0, width=0)
|
| 29 |
+
|
| 30 |
+
components.html('''
|
| 31 |
+
<!-- Google Tag Manager (noscript) -->
|
| 32 |
+
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MKBM5JQ6"
|
| 33 |
+
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
| 34 |
+
''', height=0, width=0)
|
| 35 |
+
|
| 36 |
st.markdown(
|
| 37 |
"""<style>
|
| 38 |
div[data-testid='stSidebar'] { display: none !important; }
|