Skip to main content

Track & visualize user interactions with your streamlit app

Project description

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 user interactions with your app, and visualizes the results directly in your browser. Think Google Analytics but for streamlit.

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.beta_expander().button("foo")). Instead, please use a with statement, e.g. with st.beta_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

  • You can password-protect your analytics results with streamlit_analytics.track(unsafe_password=...). The streamlit app will then ask you for this password. Do not choose an important password here – it is sent without encryption.

  • If you don't want a huge with block, you can also do:

    import streamlit_analytics
    
    streamlit_analytics.start_tracking()
    # your streamlit code here
    streamlit_analytics.stop_tracking()
    
  • Experimental: You can store analytics results as a json file by passing save_to_json="path/to/file.json" to streamlit_analytics.track or streamlit_analytics.stop_tracking. At the moment, this may lead to problems with concurrency if many users access the site at the same time.

Next steps

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

  • enable tracking on widgets created directly from beta_container, beta_expander, beta_columns
  • persist results after re-starting app

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit-analytics-0.1.2.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_analytics-0.1.2-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file streamlit-analytics-0.1.2.tar.gz.

File metadata

  • Download URL: streamlit-analytics-0.1.2.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.6

File hashes

Hashes for streamlit-analytics-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7576aeda0985e40762295e291b2c9f853f0e33c8e57bc6b54164ac861a1d9347
MD5 9f58c76a1e2051a0ed67ceab7a20d6da
BLAKE2b-256 6ed632ebb8dc47d3ff2b09a9dc8c943987cd508a0766806d3b61b8da4200293b

See more details on using hashes here.

File details

Details for the file streamlit_analytics-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: streamlit_analytics-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.6

File hashes

Hashes for streamlit_analytics-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a18dfb6a3f528a9e98fb3d03fefff4f0ce851c4a1a4169ca8c759e4698d969a0
MD5 5cba61e21e5161ef6a45a119a85ed069
BLAKE2b-256 a44af804f82e042c6cc6f710750af5d833f96c53503c667fde5f2056370d5284

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page