We are using custom checkout. And we manage to fire the tracking AFTER the purchase.
In an ideal world the email parametered mautic gif placed on the thank you page should fire first and the API call should be second. This way the anonym user would be turned into known user and couple of seconds later the purchase history would be populated.
But what happens is, that sales happens, api call made, new contact created by api and all previous tracking is unassociated with the contact.
We managed 2 workarounds, but none of them are pretty:
Fire the API call 5 min later.
We created a custom integration with a no-code API tool, where we simply wait 5 minutes before the tracking gif would populate the email.
Does work, but it’s a workaround.
Merge contacts with the same IP address in a 5 min range from the purchase event.
A script was made, that merges contacts who have the same IP 5 minutes before and after the checkout. It works, but I don’t like to run hacks like this.