Classic Live Offers (coupon & barcode generation) was due to sunset on 12/31/2019. So how do you generate a dynamic coupon & barcode for subscribers!?!? See below 🙂
As many of you are aware Salesforce is slowly sunsetting all things ‘Classic Content’. We will be moving over to Content Builder for this example.
Salesforce Marketing Cloud (SFMC) allows you to utilize a programmatic scripting language called Ampscript. Below I will provide an example of how to utilize BarCodeURL scripting to utilize a dynamic coupon & create a barcode.
|Step 1: Create a Coupon Code Data Extension|
|Step 2: Drag an HTML content block into your email|
|Step 3: Edit the HTML to utilize Step 1 data extension name|
|Step 4: Edit the HTML to change Barcode Type, etc.|
|Step 5: Import Coupon Codes into the Step 1 data extension|
Step 1: Create a coupon code data extension.
This data extension will house only your raw coupon codes. You only need to import Coupon_Code field, leaving all the other fields null when you import. The rest of the process below will fill in the remaining fields when they get assigned to a subscriber.
Create a Data Extension with the same field names, data types, nullable fields, etc…. as seen below.
Step 2: Drag a Code-Snippet content block into your email and paste the below HTML.
This is assuming you know how to create an email in SFMC. Go to your email and drag in the block. Paste the following HTML into the content block.
Paste the below HTML into the left text box. (See screenshot below – Highlighted)
This is the HTML to paste into the text box:
|%%[ SET @email = emailaddr |
SET @CouponRow = ClaimRow(“barcodetesting2”, “Assigned”, “Email”, @email)
IF EMPTY(@CouponRow) THEN
SET @couponCode = “We are out of Coupons. Please update this text.”
SET @val_couponcodenum = FIELD(@CouponRow,”Coupon_Code”)
SET @retrievebarcode = BarcodeURL(@val_couponcodenum, “Interl25″, 300, 100,1,””)
SET @updatedDate = Now(1)
UpsertDE(“barcodetesting2″,1,”Coupon_Code”, @val_couponcodenum,”ClaimedDate”, @updatedDate)
<table align=”center” cellpadding=”3″ cellspacing=”0″ style=”font: 11px sans-serif;”>
<tr align=”center” cellpadding=”3″ cellspacing=”0″ style=”font: 11px sans-serif;”>
<td> <img src=”%%=v(@retrievebarcode)=%%”> <div style=”text-align: center; color:#000000; font-size:16px; font-family:Arial,sans-serif;”> <span style=”text-align: center; color:#000000; font-size:16px; font-family:Arial,sans-serif;”>%%=v(@val_couponcodenum)=%%</span></div>
Within that same HTML, you will need to paste in your Data Extension name that you created in Step 1. You will paste the name into 2 places within the HTML. See below highlights where you would paste.
Step 4: Edit the Barcode script, in order to show your preferred barcode.
There are many different types of Barcodes. If you desire a different type of barcode you can modify the highlighted string below to show a different one. See more documentation on that here.
A few barcode example types:
Step 5: Import a Coupon Code into your data extension that you created in Step 1.
This is assuming you know how to import a file into a data extension. You only need to import your coupon code as all of the other fields will take care of themselves.
Once you import your coupon codes into the Step 1 data extension, you’ll see something like this in your Data Extension.
Congratulations! You are now ready to perform a Test Send Preview. Here’s what it will look like!!
Once you send to your subscribers (or perform a Send Preview) the Step 1 data extension will auto-assign coupon codes to the records. It will document the date & email address that was assigned to that coupon code. See below.
NOTE — If you’re sending to 100 subscribers, make sure to have 100 coupon codes imported into your coupon data extension. Your coupon quantity should match your subscriber quantity.