Is there a way to track number of visitors/unique vistors to a page?

Wondering if this is something that can be done through a plugin

Field with list of users. Workflow triggered by page load. If current user isn’t on list, add to list. Count list.

1 Like

I don’t know about a plugin, but you could just internally create your DB to store the information and when a user visits a page add that to the DB

In terms of unique visitors, it may be tricky with the DB as users not logged in, when creating entries in DB, I believe are removed after a few days and then the ‘creator’ would be blank.

The above approach by @tjc4 is workable, but my above point of users not logged in may be an issue.

Another alternative is to have a DB of visitors, when they a page is loaded create a visitor, and the creator field will be the user…then when you want to see all unique visitors you can parse the data using unique elements operator; also when you want to see how many times a single user has visited a page you can do that also, as each time they visit they create a DB entry…this will give more insight opportunity than just adding a user to a list once as that will not capture all the information that may be beneficial from creating an analytics like this.

Another example of an analytic you could glean from the DB entries of visitors is the time users visit the page and put together graphs based on number of visits compared to time of day.

1 Like

If a user isn’t logged in, how would Bubble know if a page is loaded by a user already in the DB or a new user not yet in DB?

Note: not trying to suggest that it couldn’t… genuinely curious.

I believe Bubble has cookies automatically tracking users…I have not spent much time reading up on the topic, but there should be an explanation on the forum or in the manual or reference about how Bubble handles users not logged in

Bubble has a field on every data type entry called ‘creator’ which is the current user that created that data base entry. In the method I explained, it wouldn’t matter if the user is already signed up or not, as long as the data entry is created in the DB for a page visit as ‘visitor’ the ‘created by’ field should show something; however, as mentioned I am not sure how this works for users not logged in.

1 Like

Thanks for the explanation, @boston85719

Seems Bubble does use cookies by default (per Reference) and Current User is defined by cookies (per Manual).

Learning something new everyday :slight_smile:

1 Like

I was thinking along the lines of a tracking pixel based on IP address or something, not necessarily users that signed up

If you want to ensure you only count unique visitors (at least ensure as much as is possible), then you could use IP address to check for uniqueness.

Or (perhaps an easier way) you could simply store a cookie on the browser and only count a page view if that browser hasn’t been there before (i.e. it doesn’t have the cookie).

In either case tho, I wouldn’t use a list field to do it as lists are limited to 10,000 in Bubble, so if you’re getting a lot of traffic you’ll quickly hit that limit.

Instead I’d create a new datatype called ‘page view’ and simply create a new entry from a workflow on pageload (which only runs if the cookie is not present, or if a pageview doesn’t already exist with the same IP). You could store user data, IP info, browser location/timezone, app page, and any other data you like on the record.

Or, if you really don’t even care about storing any information about the pageview, and are only interested in the number, you could just have a single entry in the database that has a number field for page views, and just add 1 to that number on every new (and unique) pageview.

3 Likes

can you show an example as i cant manage any of the actions on here, i keep having the unregistered user create many data entries instead of 1 only. i really want to find a way to do this too so any help would be really amazing, thanks

That’s a good idea - how would I specify to run if the cookie isn’t present? And collect IP info, browser location, etc

Bubble already has cookies installed so this post

would explain how to capture the current user and in effect be a unique user as Bubble has cookies doing that for you when they track users who are not logged in…naturally if they are logged in it is even simpler to recognize their log in credentials as the user…and when your user is on a different IP address and logged in as the same user, you don’t mistake the same user as a unique visitor by relying only on the IP address. Plus, you don’t need to collect the IP info or browser info.

1 Like

There are a couple of Cookie plugins (including a free one), so you can just set a cookie on the user’s browser the first time they visit (you can set how long you want it to be valid for, i.e. 30 days, 90 days, or more etc.).

Then, on page load, you can read the cookies you’ve set with the plugin, and then decide whether or not to take an action (i.e. count a new page view) based on that using conditionals.

There are also plugins for IP and Browser timezones, so check the plugin marketplace to see what’s available.

1 Like