Count page views

Hi,
Thanks for the reply!
My application has to reside on a private network so I’m not sure if the google analytics stuff can be run without sending any data outside?

In the meantime I took the idea from there to implement a simple counter.
https://discuss.streamlit.io/t/simple-example-of-persistence-and-waiting-for-input/2111

My lack of Python skills show as I wasn’t able to make this a simple integer count, I had to append to the string and use len().

@st.cache(allow_output_mutation=True)
def Pageviews():
    return []

pageviews=Pageviews()
pageviews.append('dummy')

try:
    st.markdown('Page viewed = {} times.'.format(len(pageviews)))
except ValueError:
    st.markdown('Page viewed = {} times.'.format(1))
1 Like