0

Is there a way to claim a row multiple times for the same customer using the claim row function? In my case I have a DE created with bunch of coupon codes with the required fields as per this guide ClaimRow

The code that I'm using is working fine and it's claiming a row as expected, assigning the details etc. but the issue I have is that a customer should be able to receive a coupon code multiple times if it's qualified so if the same customer came back in a month or so they should be able to get a new code from the list.

At the moment once a customer received a promo code and enter the journey second or third time (can be more) it will be assigned with the same code as I believe this is based on his ContactID that already exist in the DE. I want to be able to assign a coupon codes more than once for the same customer.

I came across this case which is similar to my issue but the solution given is only for claiming 2 rows for the same customer by setting ClaimRow1 and ClaimRow2. I assume you can continue but in my case the customers can claim a coupon multiple times so I won't know how many ClaimRows to set.

Is there a way to make this work?

Here is the code I'm suing:

var @ContactKey, @UnclaimedCodes, @couponRow,  @couponCode

set @ContactKey = AttributeValue("ContactID") 

set @UnclaimedCodes = LookupRows("TEST Dropless Coupon Codes", "IsClaimed", "False")

set @couponRow = ClaimRow("TEST Dropless Coupon Codes", "IsClaimed", "ContactKey", @ContactKey)

if Rowcount(@UnclaimedCodes) > 0 THEN

    SET @couponCode = Field(@couponRow, "CouponCode")
endif

Thank you!

1 Answer 1

2

The ClaimRow function comes with some limitations, that’s why it’s usually best to use a simple Lookup with an Update rather than using ClaimRow.

Here is what would be the main logic of the script:

  1. You are searching for a coupon which has not been claimed yet by using the lookup function:

set @couponCode = Lookup("coupons","couponCode","isClaimed", "false")

As you can see above there is a isClaimed flag in the Data extension which defines if the coupon has already been assigned or not.

  1. Then, the same row with the coupon needs to be updated in the Data Extension so that noone else can use it:

UpdateDE("coupons", 1, "couponCode", @couponCode, "isClaimed", "true", "subscriberKey", @subscriberKey)

By using the Lookup + UpdateDE combination you are not restrained by subscriber keys or any other limitations.

Here’s a video tutorial of a similar use case: https://youtu.be/1M3i5Ah_g4o

7
  • Thank you for your answer, I will give it a try. Would the 'UpdateDE' function add the date/time when the role was updated? Aug 26, 2022 at 14:51
  • You can add an additional pair of arguments to have the date added as well: UpdateData("coupons", 1, "couponCode", @couponCode, "isClaimed", "true", "subscriberKey", @subscriberKey, "claimedDate", Now())
    – zuzannamj
    Aug 26, 2022 at 14:59
  • Nikolay, if this answer helped you, please remember to mark it as accepted! Thanks
    – zuzannamj
    Aug 29, 2022 at 16:55
  • Thank you, it was very helpful. I appreciate your quick respond. Aug 30, 2022 at 11:17
  • Could this approach be an issue with triggered sends, where there may be (in theory) two or more individuals being triggered an email at the send time? Is there a way for Lookup to elegantly handle those scenarios? Oct 26, 2022 at 21:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .