I want to add google analatics to show my visitors in streamlit app.
In local, I edited index.html in streamlit package and it worked.
but I want to use GA4 in streamlit cloud, because I already deployed a web link(~~~.streamlit.app form) and since it is a widely used site, I cannot change the site address.
(by same reason, I cannot use github page or other webservice to load streamlit app by iframe.)
I tried st.markdown and st.components.v1.html to add GA4 script.
script should in class, but after i deploy in streamlit cloud, script is in class so it doesn’t work.
can i ask for solution?
If you are comfortable modifying the Streamlit library (as it sounds you are if I’m understanding you correctly), you can use that modified library on Streamlit Cloud. Package your modified Streamlit library into a wheel file and either include it with you repository to install, or host it on GitHub (or somewhere) and point to it in your requirements file.
1 Like
Oh, so the modified library file can be used on the cloud as well?
I thought there would be issues due to library duplication.
I’ll try this evening!
Yep! If you put streamlit-nightly
in your requirements file, you can use the nightly Streamlit, even though it’s a different pip listing. It will supercede the “latest” version of Streamlit that every Cloud container starts off with (the same as if you pinned an older version of Streamlit instead).