jrieke / streamlit-analytics

πŸ‘€ Track & visualize user interactions with your streamlit app
MIT License
262 stars 48 forks source link
analytics data-visualization google-analytics machine-learning monitoring streamlit webapp

streamlit-analytics  πŸ‘€

PyPi

Track & visualize user interactions with your streamlit app.

This is a small extension for the fantastic streamlit framework. With just one line of code, it counts page views, tracks all widget interactions across users, and visualizes the results directly in your browser. Think Google Analytics but for streamlit.

Alpha version, use with care.


🎈 Live Demo 🎈


Installation

pip install streamlit-analytics

How to use it

import streamlit as st
import streamlit_analytics

with streamlit_analytics.track():
    st.text_input("Write something")
    st.button("Click me")

That's it! 🎈 All page views and user inputs are now tracked and counted. Of course, you can also use any other streamlit widget in the with block (both from st. and st.sidebar.).

Note: One thing that doesn't work (yet) is tracking widgets created directly from containers, expanders, or columns (e.g. st.expander().button("foo")). Instead, please use a with statement, e.g. with st.expander(): st.button("foo").

To view the results, open your app like normal and append ?analytics=on to the URL (e.g. http://localhost:8501/?analytics=on). The results are then shown directly below your app (see image above).

More options

TODO

PRs are welcome! If you want to work on any of these things, please open an issue to coordinate.