You can link a donation to a purchase through a technical implementation, by setting up a webhook notification service to receive and store the PSP reference from the purchase. This allows you to correlate it with payment data, linking both transactions and providing enhanced insights into shopping behavior in your online and physical stores.
Find more technical details on implementing webhooks in your Customer Area and how this applies to Giving webhooks specifically for your component, API, or in-store integration.