0

I am struggling with ampscript. I am unable to use the built in dynamic content function to display the content in the email.

The scenario: I have an email which I am going to send to my master data extension. Within this email I have a content block, this specific content block (A) will be visible to the majority of my database (master list) but to a smaller group I want to display a different content clock (B). The subscribers supposed to get version B of the content block are present in a separate data extension.

The problem is that I can't create it as normal dynamic content within the email, since I don't have a attribute in either of the data extensions I can filter on. The subscribers in the DE who are supposed to get version b of the content are also in my Master DE

I have been told that I can do this using ampscript.

My thought is to use something:

%%[IF ??? == "" THEN ]%% %%=ContentBlockbyId("CONTENTB")=%%
%%[ ELSE ]%% %%=ContentBlockbyId("CONTENTA")=%%

But I am unsure how to write it exactly, and how to state that if you are in data extension B, you see version B and not version A, even though you are also in data extension A.

Any ideas/help?

1

You can use lookuprows() function to identify the subscriber in data extension B where you have the subscriber stored for receiving an email with Content B. Im assuming you are using data extension A to send out an email.

%%[
    SET @delookup = LOOKUPROWS("DataExtensionB","SubscriberKey", _SubscriberKey)
    
IF ROWCOUNT(@delookup) != 0 then
]%%

%%=ContentBlockbyId("CONTENTB")=%%

%%[ELSE]%%

%%=ContentBlockbyId("CONTENTA")=%%

%%[
ENDIF
]%%
0

You have to use LookupRows

Assuming your master DE and Version B DE have the same primary key and is related to subscriber key in the send relationship

Your code would look something like this:

%%[set @subkey= _subscriberkey /* Subscriber in the send context */ 
set @rows = LookupRows("VersionBDEName","PrimaryKey", @subkey)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then]%%
%%=ContentBlockbyId("CONTENTB")=%%
%%[ELSE]%%
%%=ContentBlockbyId("CONTENTA")=%%
%%[ENDIF]%%

 

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.