I want to get get views-statistics from my app. Saw some older posts on this, but isn’t there a functions for this now? Searched in the docs but could not find it.
Regards
Niklas
I want to get get views-statistics from my app. Saw some older posts on this, but isn’t there a functions for this now? Searched in the docs but could not find it.
Regards
Niklas
Quick’n dirty fix could be to write to a database when the page is loaded (and possible using st.cache to avoid an artificial number of visitors evertime the user clicks a widget) :
import streamlit as st
import sqlite3
@st.cache
def count_visitor():
conn = sqlite3.connect("/path/to/database.db")
cur = conn.cursor()
cur.execute("UPDATE name_of_table SET total_visitors = total_visitors + " + str(1))
conn.commit()
conn.close()
count_visitor()
st.header(“Welcome to my website”)
Hey!
Do try the Streamlit Analytics library, however, this may throw some errors while deploying on Streamlit Cloud with the updated latest Streamlit version.
Reference: streamlit-analytics · PyPI
Hope this helps!
Thanks!
Thanks! I don’t have a database for this application though. I could work just update a file instead I guess.
Yes, that would probably work
@niklas_ema You can try a simple badge counter.
st.sidebar.markdown('')
Thank you for your badge counter method.