Is there a way to add a website visit counter on a Streamlit/Heroku app?

Does anyone know of a way to add a website visit counter to a streamlit app hosted on Heroku?

Hi @chefnewman -

There isn’t a built-in way to do this, but one could imagine a simplistic counter by reading/writing to a text file each time the page is loaded. Create a file with one line of 0, read the line in at the top of the page, increment by 1, then write back out to the file. There’s obviously the chance of a race condition with multiple people using the app, but it would persist across sessions.

Best,
Randy

1 Like