Track browser actions: Reload/refresh, backwards, forwards
Tracking how the user reached your page
With the introduction of the Performance API, you can track browser actions such as reloads, forwards and backwards.
Tracking reloads, backs, and forwards
performance.getEntriesByType("navigation")[0]?.type;
This little snippet will return the type of navigation event.