This is referring to a field in the coupon data extension, and the value you would like to populate it with. You can populate extra fields in the coupon data extension so that you can reference information about who claimed the coupon. The example on ET's help docs uses JobID, ListID, BatchID, SubscriberID, EmailAddress and ClaimedDate.
The reason you are getting an error because you are trying to insert the value of the attribute newsletter_coupon_20_key into the field newsletter_coupon_20_key in the data extension newsletter_coupon_20. This attribute either does not exist in your profile attributes, or in the Sendable DE you are attempting to deploy to, or the field "newsletter_coupon_20_key" does not exist in the coupon DE.
If you want the bare minimum for claiming a row, you could simply write:
SET @CouponRow = ClaimRow("newsletter_coupon_20", "IsClaimed")
However I do not recommend this approach because you are left with almost no information on who claimed the coupon or when that happened.
My suggestion is to set up the coupon DE using ET's example specification, which looks like this:
Then, the code to claim a row would look like this:
set @CouponRow = ClaimRow("newsletter_coupon_20", "IsClaimed", "JobID", JobID, "ListID", ListID, "BatchID", _JobSubscriberBatchID, "SubscriberID", SubscriberID,"EmailAddress",EmailAddress)
(Notice the correlation between the DE fields, and the name/value pairs in the function)
You may also wish to add additional fields to the coupon DE. For instance you may want to add a "CampaignName" field, and populate it with the friendly name "Newsletter". Adding that would look something like this:
set @CouponRow = ClaimRow("newsletter_coupon_20", "IsClaimed", "CampaignName", "Newsletter")
Note that "Newsletter" is a string, not a variable, which is why it is in quotes.
First, I'd suggest setting a primary key on your
MatthewDataExtension Data Extension, since the
ClaimRow() function is doing an update.
Also, every pair of
ClaimRow() parameters after the 2nd needs to be the variable name and then the variable value -- in order to retrieve the proper row. So if you're going to update
StoreCouponCode, your function would be this:
set @numberCustomer = AttributeValue("Customer_No")
set @WebPromoCode = AttributeValue("WebPromoCode")
set @StoreCouponCode = AttributeValue("StoreCouponCode")
set @couponDataExtensionRow = ClaimRow("MatthewDataExtension", "isClaimed", "WebPromoCode", @WebPromoCode, "StoreCouponCode", @StoreCouponCode , "Customer_No", @numberCustomer)
/* Snip */
If it helps, here's my go-to coupon claiming AMPScript:
var @couponRow, @couponCode, @rows, @row, @emailaddr
set @emailaddr = AttributeValue("emailaddr")
set @rows = LookupRows("couponCodes","EmailAddress",@emailaddr)
if rowcount(@rows) > 0 then
set @row = Row(@rows,1)
set @couponCode= field(@row,"couponCode")
if _messagecontext == "PREVIEW" then
set @couponCode = "XX TEST XX"
set @couponRow = ClaimRow("couponCodes","IsClaimed","EmailAddress",emailaddr)
if empty(@couponRow) then
/* You can do other error handling here if you want.*/
/* This aborts the send */
raiseError("no more coupons available")
set @couponCode= field(@couponRow,"couponCode")
Here's your coupon code: %%=v(@couponCode)=%%
There are a few more details about the Data Extension on in my blog post on the subject.
I made it work this way:
TreatAsContent will execute the code string and set the @CouponRow for later use.
I sometimes had an issue with the code erroring but I fixed it by closing and re-opening the AMPScript block tags around the TreatAsContent this way: