Tracking Traffic

I deployed my first streamline app and I noticed that in the analysis section, the viewers I can see are only streamline users. So I tried to insert a google analytics code in it so as to get some traffic infos but it did not work. Does somebody has any tips ? Is it even possible to have the full analysis infos when we deploy an app on streamlit ?

Hello @Terre-ronce welcome to the streamlit community,

By default, Streamlit doesn’t provide built-in analytics functionality or the ability to insert Google Analytics code directly into your app. However, there are a couple of alternative approaches you can consider to gather traffic information and analytics for your deployed Streamlit app.

Integrate with external analytics services:

  • To obtain more comprehensive analytics, you can integrate your Streamlit app with external analytics services such as Google Analytics or Mixpanel.
  • Instead of directly inserting the analytics code into your Streamlit app, you can wrap your Streamlit app within a web application framework like Flask or Django.
  • Set up the analytics service within the web application framework and embed your Streamlit app as a component.
  • This way, you can take advantage of the analytics capabilities provided by the web framework and the integrated analytics service.

I hope this helps you,

Cheers!

1 Like

Hello, thanks for your answer. Indeed wrapping the app with flask seems to work, however I think I can’t seem to do it correctly. And I don’t know how to use django :joy_cat:.

So instead I used the st.session_state to just know how many time somebody has been on the form and how many time somebody submitted it. This gives me a few informations.

And I would like to know if there is a method in streamlit to know the time somebody spent on the site, something like a clock.

I just realized that my method only works for a single user at a time…

I had the same question and this thread answered it, thanks for posting it.

To streamlit team @sakp7
Is streamlit team considering adding a built-in analytics feature in the future? at least offer a way to integrate 3rd party tools like Google Analytics at the streamlit level instead of having to wrap it to a web framework.

Most of streamlit users are DS or DA using streamlit to build MVP:

  1. Analytics is important for owner to understand the MVP performance/value
  2. Flask/Django is still too heavy for DS or DA, imaging the learn-curve to learn them to wrap the analytics feature(and it shouldn’t be this hard)

Hope our voice can be heard, cheers!

I am also waiting for this feature