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.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.