Variable at general level & Current user Vs Current Page User

Hello everybody,
I would like to ask you 2 questions:

  1. Is it possible to create a variable to the highest level, so I can i have access through the entire app?
  2. How can I translate this condition : If a user sees this page than do something.
    To "see " a page what does it mean? that the current user is logged out ?
    An example of app could be, a viewer counter.
    Thank you very much for your explanation

Hey Nic,

There isn’t a direct way to create global variables, but you can achieve that by setting a state on your Page element (any element would work, setting it on the Page just makes it more manageable imo).

Secondly, for page views, you can add a WF to run a counter that triggers ‘on page load’. Within this WF, you could use the action conditionals to make the counter work differently based on the value of ‘Current User is logged in

Hi, thank you for your reply.
In Regards of the second question, i was thinking to a view counter but for any user that visits the page, rather than a registered user.
Moreover If i use a state, i believe after it reloads the page the state resets right?
Thank you for your help

Yes, states reset on page load.
For persistent variables I think you’d be better off using the database.
I’ve seen apps that have a DB table (DB type) dedicated to app variables and usually only have 1 entry. You could do something like that.

For the views counter, another approach could be creating a list of users that have viewed the page. This makes a list of unique ids of users that have viewed the page.
Unregistered users are also assigned ids by Bubble, so this will work.

Thank you for your reply @atomicfusion .
Yes I thought about it, I will try to work with a different approach to see if it works.
The only thing is I need to understand how an User “views” the page. When the Current User is a Current user? what defines “views the page”

Thank you for your help

A page load should count as a ‘view’

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