Below I have added simple coupon code implementation using ampscript.
Some important points to note:
- I have the messagecontext as preview - when sending it should be send
- My data extension is called Coupons ( this should be replaced with your own if needed)
- This is merely a skeleton and you can write so much more to the data extension :-)
%%[
var @em, @couponRow, @couponCode
if _messagecontext == "PREVIEW" then
set @couponCode = "XX TEST XX"
else
/* include your sendable attribute/column here */
set @em = AttributeValue("emailAddr")
set @em = AttributeValue("emailAddr")
set @couponRow = ClaimRow("Coupons", "IsClaimed", "EmailAddress", @em)
if empty(@couponRow) then
/* You can do other error handling here if you want.*/
/* This aborts the send */
RaiseError("No coupons available", false)
/* This aborts the send */
RaiseError("No coupons available", false)
else
SET @couponCode = Field(@couponRow, "CouponCode")
endif
endif
]%%
Here's your coupon code: %%=v(@couponCode)=%%
My the force be with you.
Kind Regards
Jerome
No comments:
Post a Comment