I was able to figure out when a user launches my app by creating SessionState object. But how can I know if that user closes the webpage and ends the session?
Hi @swswsw, welcome to the Streamlit community!
This is an open question for the digital analytics community, and in the 10 years or so I’ve paid attention to that industry, there really isn’t a good question. The issue is that it’s difficult to tell the difference between someone not doing something on a page vs. they left the page.
You can try to implement some fancy javascript to either ping a “heartbeat” back to a listener of some sort, or you can try and intercept the back button or link clicking, but in the end that’s a pretty aggressive tactic towards your users.
What is your use case? Maybe there’s an easier way to achieve what you are looking for.