💬 RevOps Discussions

Top Contributor

Unique/Dynamic Coupon Codes

I’m wondering if anyone here has done unique/dynamic coupon codes with HubSpot before?
For example, this is something we would like to do for a birthday campaign - to provide a discount on their next purchase with their unique coupon code, which is valid for say 30 days from when it was sent.
How this could be set up will vary depending on systems outside of HubSpot, but curious to see what anyone has done here.
3 Replies 3

Unique/Dynamic Coupon Codes

Hey ridingforlife,


This is very similar to a micro-influencer campaign we setup last year using dynamic discount codes that work in Shopify, which got triggered by Hubspot. Since the tools are easy to use, we completed this build in about 6 hours with two people. We've run it for a few months, and made over 1,000 variable discounts, so it's proven to be very reliable. Here's the outline of what we did.


Step 1: Hubspot - Setup a workflow to initiate a new discount code

Trigger: Can be your choice. ( We triggered based on a form fill, but you could easily use a date field )

Action: Send Webhook. I will come back to this in a couple steps.


Step 2: Hubspot - Add a discount code property to contact records

Single line text is the best option. This is where your birthday discount code will go. We called our property "Influencer Registered Discount Code".


Step 3: Hubspot - Create a workflow to alert the contact of their discount

Trigger: Manual

Action: Send Email. Create a marketing email that will send the discount code. Use a personalization token ( Step 2 ) where you want to place the discount code.


Step 4: Shopify - Get an API key from your shopify account

You will need to get an api key for your account, and set permissions to discounts & price rules only. Here is an article on how to get credential from the shopify admin console.


Step 5: GCP - Build & deploy your new discount code script

We use Google Cloud Functions to do this. It is a tool inside the Google Cloud Platform. Without getting too technical, you write about five steps in javascript, click run, and let marketing automation magic happen. The five steps are,


  1. Catch the webhook from Step 1
  2. Create a price rule code in Shopify ( this is how the discount code works )
  3. Create a dscount code in Shopify ( this is the actual code the customer gets )
  4. Update the Hubspot contact with the discount code you made ( Update the property from Step 2 )
  5. Enroll the contact in the workflow from Step 3


Hopefully this helps. If you decide to go the shopify route I can provide some example code if you need help on step 5. Good luck!


Unique/Dynamic Coupon Codes

Any ideas on how to do this just using HubSpot and maybe Google forms?

Top Contributor

Unique/Dynamic Coupon Codes

Hey @Aaron-WC,


This is great! We don't use Shopify - I work for an airline, so we use industry specific platforms - but this will definitely help steer us in the right direction, so thank you so much for sharing!