With a third-party email marketing app, you could create an automated email campaign that sends out a link that directs customers who have purchased Product X, Y, or Z to register to win a gift. An email marketing app such as Mailchimp does support advanced segmentation that allows you to create an email list based on the 'Product Vendor' field in Shopify. So for those gift products, you could enter a unique name in the 'Vendor' field that only those products have. More on that can be found here in their documentation. They have a guide here on integrating their software onto the Shopify platform.
If there is anything else I can help you with, please let me know.