Best way to run sitewide background task, that runs even if page is navigated away from

I want to update user profile on my site with the latest orders , after they make a purchase on my site.

It needs a few seconds to retrieve as sometimes it needs multiple tries.
I call the API action repeatedly (with a Page flow) until latest data is received, but i want it to work even if user navigates from that page to another. How should i do that?

Community Page
Last updated: