Using a DB to implement a view counter

Hi, i’ve just started using streamlit in the last few days and i’m really enjoying it.
I want to add a view counter to my app that is deployed on streamlit cloud.

From what I understand there isn’t an inbuilt functionality for this and some have suggested using the Streamlit Analytics library, however i want a counter without having to type in “analytics=on” in the url bar.
I guess the best thing i could do is connect to a database to hold the view count, i’ve tried connecting to firestore with the tutorial but i keep running into errors. Is there any other cloud database service one would recommend?

Hey @martyash,

I’d recommend checking out st.experimental_connection as well as our docs on connecting to data sources, including BigQuery, MySQL, Google Sheets, Supabase, MongoDB, and more.

Also, if you can share a code snippet and the error message you’re seeing, we can help you figure out how to successfully connect to Firestore.

1 Like

Hi Caroline i ended up figuring it out , i needed to add a library that wasn’t mentioned in the blog post but a helpful person mentioned it in the comments!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.