How would the coupon be given or determine which users to generate and give It to? I may have a premade solution that I could customize.
I create an automatic discount plugin for a past client. When a user clicks to share the owners page, the plugin generates a one time unique string of 10 ascii letter length combination. It takes that randomly generated string, saves it to the database as a `shop_coupon` for woocommerce and attaches a cookie with the same value to the user. When the user goes to check out, it is automatically applied with no hassle.
If you give me a bit more information, I might be able to fine tune it for your needs.