How to track purchase back to the ad that brought them to the store page

I need a way to track the purchase of an individual item back to what social media ad caused the sale. For example, I would like to see this information:

User: “John Doe”

Item Purchased: “Tee Shirt”

AD Link clicked: “example URL”

Also, I need the specific ad that caused the purchase, for example, if it were an ad on Facebook, I would want to see which exact post was clicked on. Is this possible? Any help would be great!