You are here:
Offer a Limited Number of Coupon Codes in MobileConnect
You can dynamically assign coupon codes using AMPscript and a data extension in Marketing Cloud Engagement.
For example, Northern Trail Outfitters wants to distribute a limited number of coupon codes to customers, so they create a text response message tied to a data extension via AMPscript. When customers send a message to the text response keyword, they receive a coupon code from the data extension. When the coupon codes are sent out, the customer receives a message thanking them for their response and explaining that Northern Trail Outfitters sent out all available codes.
- Create a .csv file that contains the coupon codes.
-
Create a data extension that contains these required
columns:
- IsClaimed—A Boolean value that indicates whether the code is claimed or unclaimed. 0 is false, unclaimed. 1 is true, claimed.
- CouponCode—A string value that contains the coupon code
- SubscriberKey—A string value that contains the subscriber key or contact key for the customer who claims the code
- Import your data from the .csv file into the data extension.
-
Create a text response message. Include the following AMPscript
in the response message.
ClaimRowDEis the external key for the example data extension.%%[VAR @CouponRow SET @CouponRow = ClaimRow("ClaimRowDE", "IsClaimed", "SubscriberKey", MOBILE_NUMBER) IF EMPTY(@CouponRow) THEN ]%%Sorry - No coupons available.%%[ ELSE ]%%Congrats! Your promo code is %%=FIELD(@CouponRow,"CouponCode")=%% and expires in 3 days. Thanks for Responding! %%[ENDIF]%% - Schedule or send the text response message.

