0

Sorry for the weird title, but this is an odd one I think.

We have been testing a unique coupon code send using a data extension. There are many examples on the internet of using AMPScript to do this, ie, go through a series of rows of unique coupon codes and use each code only once.

The data extension has FirstName, CouponCode, EmailAddress. The csv we uploaded matches this exactly. The email template has merge fields for FirstName and EmailAddress

This is the problem we have experienced:

  1. Upload the csv - check in the data extension an the records are there and the name and email in each row match
  2. Send the email. Emails all send just fine, except...
  3. Received emails have the wrong name for the email address
  4. Recheck the records in data extension, and they are now jumbled (ie the name and email in each row are not matching)

After much messing around, we figured out that the position of the FirstName in the list of records does not change, but the position of the email address does. The email addressed become sorted in alphabetical order after we send. This is what causes the mismatch.

Records in data extension before send:

| Name  | Email               |
| Jeff      | jeff@test.com |
| Ben     | ben@test.com |

Records in data extension after send:

| Name  | Email               |
| Jeff      | ben@test.com |
| Ben     | jeff@test.com |

So the question is, why? Does anybody know?

Below is amp script code for reference. Thanks

%%[

var @em, @CouponRow, @CouponCode, @FirstName

if _messagecontext == "PREVIEW" then

    set @FirstName = "XX TEST NAME XX"
    set @couponCode = "XX TEST CODE XX"

else

    /* include your sendable attribute/column here */
    set @em = AttributeValue("emailAddr") 

    set @CouponRow = ClaimRow("TEST_Vouchers", "isClaimed", "Email", @em)

    if empty(@CouponRow) then

        /* You can do other error handling here if you want.*/
        /* This aborts the send */    
        RaiseError("No coupons available", false) 

    else
        SET @FirstName = Field(@CouponRow, "FirstName")
        SET @CouponCode = Field(@CouponRow, "CouponCode")
    endif

endif

]%%

Merge fields are:

%%=v(@FirstName)=%%

%%=v(@CouponCode)=%%

  • The sending DE should not change as a result of using a claimrow function. It should only be affecting TEST_Vouchers. Looks like you should just be using a lookup instead of claimrow if all of the coupons are predetermined. – Adam Spriggs Nov 6 '17 at 6:28
  • Sorry, just realised I omitted from the question: in our case, TEST_Vouchers is our sending DE. So it contains the email address, name, and voucher code. – Ben Nov 6 '17 at 22:58
0

Doesn't sound like you need to use claimRow() at all. Since you're sending to the TEST_Vouchers DE that has the coupon, you can just retrieve the coupon from the send context.

%%[

var @couponCode
set @couponCode = AttributeValue("CouponCode")

]%%

<br>Your coupon is: %%=v(@couponCode)=%%

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.