Dynamic Coupon Code Generation for HubSpot

The Coupon Code Generation feature makes it easier to offer (via email) the prospect/customer a unique one time use coupon code when they take some action on your web site. This coupon can only be redeemed once and cannot be shared.

Coupon Code Generation
is a Unific feature that's available to our paid plans only. 

In this article,  we are going to give an overview of Unific + HUBSPOT COUPON CODE feature.  The purpose is to generate coupon codes that can expire or that are one time use and are unique to that customer that cannot be put onto websites like “retail me not” or similar sites where a coupon can be used.


Unific instructions to create the coupon code;

  • Click on the "Add Coupon" icon
  • Enter the "Coupon Snippet Name" - this is an internal naming convention for your promotion ex: 10percentoff
  • Enter the "Coupon Code Format" (not required) -  the "Suffix" this is a static starting alpha numeric digit that you could put into the coupon each time, that will then be proceeded by a bunch of random letter and numbers afterwards.  You probably want to also have a "Prefix" that is set so you can determine what group a particular coupon belongs to when synced to Hubspot.  

*****Note:  You do not have to have a prefix and a merge field when creating a coupon code. You do however have to choose one or the other. There is a second checkbox under the coupon code generation called "Format" and this is where you can choose whether you want a prefix or a merge field.  You can see the format of the coupon set by looking at the sample section.

ie: If you don't want a prefix, you can select the prefix in the format box and then erase any text you might have displayed in the Prefix box and then you can save without any errors.

  • Enter a "Discount Value" which is either a Percentage, a Fixed Amount, or Free Shipping.
  • Select if you want the discount to be "Applied to" the Entire Order or if you want it to be Product Specific.
  • Choose the "Active Dates" of when you want to run this discount set either as 'Always Active', 'Date in the future', or select a Specific date range to start and stop.
  • Select the "Coupon Code Offer Property"- this is a single line text field Unific creates for you by default in your HubSpot portal that will be used in the email template as a personalization token.  This will be merged into the workflow you will create later in the instructions.
  • Select the "Coupon Code Expiration Date Property"- this is a date picker field that Unific also creates for you by default in your HubSpot portal that will be used in the email template as a personalization token that will be merged into workflow you create as well.
  •  Click "Save" to create the http post that is going to be used in HubSpot workflow to tell Unific to generate the one time use code.

Please note that any time a coupon code is used, Unific will update 2 properties in HubSpot as part of your subscription which includes;

  • Coupon Codes Used- list of all codes utilized
  • Last Coupon Codes Used-most recent utilized


How to Configure the http post in HubSpot:

Please note that you will need to create 2 workflows from scratch inside of Hubspot and label as follows; 

  • Generate Coupon Code
  • Deliver Coupon Code with Reminder

Generate the Coupon Code Workflow steps:

  • Choose your enrollment method- Enroll whatever method you want ie. webform submission, pop-up submission etc.
  • Select the "trigger a webhook action"-  You will need to select "Post" and then copy and paste the http post from the Unific admin portal to put into the trigger webhook.  This post sends a request to our servers to generate  the coupon code with the criteria you have set up in the Discount set.

Deliver the Coupon Code Workflow steps:

The delivery part is going to take place once Unific posts the dynamic code to the "Coupon Code Offer and Expiration Property".  

  • You should set the enrollment trigger of this workflow so that it is not fired until the field value is known for the "Coupon Code Offer Property".
  • The next step is to send an email.  Be sure to customize your email with the 2 personalization tokens for "Coupon Code Property" and "Coupon Code Expiration".
  • You can then add some delay timers to the workflow to send reminder emails You can time this action to wait 5 days then 1 day before expiration etc (depending on what your expiration date is actually set as). 
  • Don’t forget to set the goal in the workflow-  You can either choose a condition that states if the "Last Coupon Code Used" property contains whatever prefix you have assigned or you can set a goal to remove them if any order is placed and they enter our "Advanced Order Detection" workflow which is documented in a separate article.

This is a structure for how to make this work, once you understand this, you can alter to better suit your business and best suit your coupon code delivery.



If you generate a large batch (ex: 5,000) coupon codes for a Shopify store using the Unific Coupon Generator it will take approx. 2 hours for Shopify to accept, process, and create that large quantity of coupons and then about 1.5 hours after that for Hubspot to sync all the coupon codes to the respective contact records. For this reason we recommend generating coupons on demand or in small batches so that the requests are spread over time.


Next up: Historical Data Sync