Great question — answering as the UphillTech team:
You didn't do enough debugging. A switch in attribution like that is only possible with complete session breakage. It's common when you either have checkout on a different TLD (top-level-domain) so the user id changes too or when something interferes with the referrer. This happens a lot on shopify backend due to how they've implemented their checkout. And there are fixes for it. Just to answer your question in bold: Yes, there is. Google keeps track of clients using the _ga cookie. Just make sure it's not being interfered with. As you may know, cookies are TLD-specific, so if TLD changes, you can't expect the ga library to be able to keep track of the client. What you do to mitigate it? In...
Full answer by BNazaruk: https://webmasters.stackexchange.com/a/138766 (CC BY-SA 4.0).
Need it done for your business? UphillTech.