Display Number of Visitors in the Past 30 Days

Hello all! First post on this forum, so I apologize if this is the wrong category. I’ve been building my app in Bubble for the past couple weeks and this forum has been a great help. I am running into some issues that I need help solving — which I think will be helpful for other users, too.

Record the number of visitors that have visited a public profile page and display it on a user dashboard

Attempt 1
My first try at tackling this problem was to use Google Analytics to capture unique visitors on a particular page. I installed two plugins: the free Google Analytics plugin and the $35 Google Analytics with Webhook plugin. I poked around the docs and got lost. I’m not sure how to pull in the data I need from Google Analytics and display it on the user’s dashboard.

Attempt 2
The solution I have right now is simple. I have created a User variable in my database named “Profile Visitors.” My workflow is setup to when the profile page is loaded it iterates the variable by one.


The problem with this solution is that 1) there’s no way to see visitors for only the past 30 days. It will just add one number every time the page loads. 2) It actually shows page loads, not unique visitors. One visitor could load the page 100 times and my number increases by 100 even though it is just one person.

1 Like

Welcome to Bubble! There are a couple of ways of tackling this, depending on how flexible of a solution that you’re looking for.

  • Simple way: on the given user’s profile page, store a a list of users on the given user being viewed. When the page is loaded, you have a workflow that scans the list to see if the current user exists within that list of users. If they aren’t in the list, then the user is added. However, this starts introducing issues. (Ie. how do you know when 30 days has passed to remove them? You could schedule an API workflow to remove them, but what if they visit their profile in the intervening time? That breaks pretty quickly!).

  • Better way: create a notion of “view records” as a data type. So, every time that a profile is viewed, you create a new “record” of that viewing in the database. Then, you save that list of view records as a list on the user being viewed. With the created objects, you’re automatically saving the “current user” and created date. Now, it’s just a matter of setting up some search constraints to show the list of users who have viewed in the last 30 days, displaying count totals, etc. (You can control for the count totals by using the :unique modifier when working with the list of users).

Dan (creator of LearnTo - 15+ hours of Bubble tutorials and live coaching)


This is excellent, Dan, thank you! I like the “better way” of creating a view records as a data type. It didn’t cross my mind to think that way.

I’m having trouble setting up a search for constraint. I haven’t worked with dates much in Bubble. I assume I need to make a constraint of something like:

Type: Profile View Records
Constraint: Created Date > Today’s date - 30 days

Not sure how to do that constraint. Any tips?

Use the “current date and time” function (…should’ve phrased as that since that’s Bubble’s way of describing it). You can also “normalize” the date (ie. set to midnight) using the “change hours to” and “change minutes to” functions.


For those following along, this is what I ended up doing to get the text field to show visitors in the past 30 days


what does the unique element do? i did this but very different, on page load or click to someones page i create a workflow data.
create a new (visitors)
only when search for visitors: count is 0

this way i get views from registered and non registered users :slight_smile:

1 Like

@mrzbektas - Do you have an example in an editor? I’d love to know how you recorded total views and unique views for both logged in users and not logged in, the majority of my views will be not logged in.

Can you do unique non-logged in users?