0

In SFMC we need to show a block after the customers 4th purchase. This means when the customer have bought: 4, 8, 12 and so on.

I know I could use a dynamic content block and then you add the numbers manually, but I was wondering if it was possible to use ampscript that do the count for me. If so, how would that look like?

1 Answer 1

0

I will suggest you to use combination fo LookupRows, RowCount and Mod to count the orders made by this customer, and verify if the number of orders leaves any remainder when calculated by 4:

%%[

VAR @customerid, @orderrows, @rowCount, @modulo

SET @customerid = AttributeValue("SubscriberKey") /* value from attribute or DE column in send context */
SET @orderrows = LookupRows("Orders","customerid", @customerid)
SET @rowCount = rowcount(@orderrows)

SET @modulo  = mod(@rowCount, 4)
IF (@rowCount > 0 AND @modulo == 0) THEN
ContentBlockByKey("myContentBlock")
ENDIF
]%%

Then use ContentBlockByKey to fetch your content block, if the statement evaluates to true.

2
  • Would you then under @purchase add the content block id instead or how would you do that? :)
    – Louise
    Commented Jan 11, 2021 at 10:39
  • I have updated my answer, @Louise - you can use ContentBlockByKey to display your content block conditionally. Commented Jan 11, 2021 at 10:44

You must log in to answer this question.

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