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?

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.

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

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.