How can I display the number of views a url has?

I´m building a social media platform and need to display the number of views each profile has. Is this possible?

Sure, you can save a view to the database every time it is loaded, or every time a unique visitor loads it. You can also get numbers like this out of tools such as Google Analytics, but a simple counter in Bubble might be easier if you want to display it to visitors.

Hi Peter,

not sure what you mean. Are you suggesting I create 1 entry in the database per each visit? wouldn´t that make the database huge?

Otherwise, how do I display the number of views?
I want to display the same way bubble displays on this forum (attached)


You don’t need one entry per hit, but I presume each profile has a database type (could be USER, but you might have chosen something else). I’m gonna call it PROFILE just for the sake of this example.

Create a field on the PROFILE data type called “view counter”, and set it to number. Set the default value to 0. Every time the profile loads, you use a workflow to set view counter = view counter + 1. So this just takes the value of view counter and adds one.

I don’t know how you load your profile page, so I can’t tell you where in the workflow to put it, but this would make a page counter in its simplest form. Also, if you want to separate between unique views and total views, you need to define that in the workflow as well.

If you share some more details or share the app itself, it’s easier to be more specific.

Thanks again petter!
Fields were expressed just as you thought. Workflow now registers views correctly. Had problems as I pointed view counter to current user instead of current PAGE user.

How can I make it work with unique visitors, in the most simple way?

1 Like

Well, you could, instead of a counter, save a list of Users instead, in the PROFILE data type. So you have a field that’s a list of Users. When I visit the page, my User is added to that list, as long as it’s not already in it. And to view the total number of unique views, you use the :count function.

There might be a more efficient way to do this, but it should work.


This topic was automatically closed after 70 days. New replies are no longer allowed.