Storing the page got complicated in my case, because I would need to store a chain of previous pages in some circumstances.
Instead, I made a custom. back button for this specific page and used the following custom JS when the custom back button is clicked
history.go(-2)