Do page-load workflows run again when a visitor opens another record of the same page?
Yes. On your published TeleportHQ site, a page with Page is Loaded, An Element Becomes Visible or Component is Loaded workflows, or with states filled from a data source, starts over each time a visitor arrives at it, even from that same page: for example from one product's details page to the next product. Those workflows run again and those states are read again, as on a first visit. To run a workflow only once per visit, let it remember in the visitor's browser that it already ran.
When a TeleportHQ page starts over
On your published TeleportHQ site, a page starts over when a visitor who is on it:
- opens another record of the same details page, for example the next product or the next post (see How to create a page for each item);
- follows a link that changes the part of the address after
?, for example from/shop?category=cakesto/shop?category=bread; - switches language with your language switcher (see How to add a language switcher);
- clicks a link to the page they are already on.
The page doesn't start over when:
- the visitor jumps to a part of the same page, with an address that only changes after
#; - a list's filter, sort, search or page buttons write the visitor's choice into the address.
Opening a different page loads that page, so its own page-load workflows run there, as always.
A workflow counts when it belongs to the page or to a component on it. Pages without such workflows or states have nothing to run again.
Why TeleportHQ starts the page over
A TeleportHQ site moves from page to page without reloading the browser window. When the visitor stays on the same page and only the record, the address or the language changes, the page would stay as it was: its states filled from a data source would keep the old values, and the workflows that set up the page wouldn't run for the new record. So TeleportHQ starts the page over, as if the visitor had opened that address directly.
When a TeleportHQ page starts over:
- Page is Loaded and Component is Loaded workflows run again. A run still waiting for its Delay After Load (ms) is cancelled, and the new arrival starts its own wait.
- An Element Becomes Visible workflows run again when their element is in view.
- States filled from a data source are read again, for the record that is now open.
- The page's other states, and those of its components, go back to their starting values. For example, a tab the visitor opened goes back to the tab the page starts with. Global states keep their values.
How to run a TeleportHQ workflow only once per visit
To run a page-load workflow only once per visit, for example a welcome message, let it leave a note in the visitor's browser and check that note first.
1. Check whether the workflow already ran
- Open the workflow in the Workflows panel.
- Click the round + under the Page is Loaded trigger and add Get from SessionStorage (category Storage).
- In its Storage Key, type a name for the note, for example
welcomeShown. - Under it, add an If Statement and set Condition Type to Simple Comparison.
- Next to Left Value, click Select from context and pick Exists under the Get from SessionStorage step.
- Set Operator to is false.
2. Add the steps that run once
- Click the green + under the If Statement (tooltip Add true branch) and add the steps that must run once, for example Show Toast.
- After those steps, add Set in SessionStorage.
- Type the same Storage Key,
welcomeShown, and a Value, for exampleyes. - Publish your site.
The note lasts until the visitor closes the browser tab. To run the steps once per browser, across visits, use Get from LocalStorage and Set in LocalStorage instead. See How to use data from one workflow step in the next.
The check has to come before the other steps. To add it to a workflow that already has steps, create a new workflow with the same trigger and build the check as above. Then copy the old workflow's steps, paste them, connect them to the true path, and delete the old workflow. See Copy, paste and tidy steps.
Check that it worked
On your published site, open the page, then open another record of it, for example the next product. A workflow without the check runs again. A workflow with the check doesn't, until you open the site in a new tab.