0

I am hoping to get some help from you guys. We have a Scenario that we wan to send different content to people who attended our Web_Event. In this case, we have Event A, Event B, and Event C. For some reason that we have three data extensions for all the information. First Data extension (Send) contents Subscriber key, first name, and email address. The second one (Event) contains Event ID, Email address, and First name, Third one (Event detail) contains Event ID and Event Name. The issue we are facing is, we tried to show different content based on which event they attended, but for people that attended two or more events, we will send them combined content( Fro example, if a person watched Event A, show (1), Event B, show (2), or Event A and B, show 1 and 2.)

Here is the code we have but we are not able to combine IF statements, if there any other ways to do this?

%%[ 

var @Subkey, @EmailAddress, @FirstName, @Event_ID, @Event_Name 

Set @Subkey = Subscriberkey 
Set @EmailAddress = EmailAddress
Set @FirstName = FirstName
Set @Event_ID = Lookup('event','Event_ID','Email_address',@EmailAddress)
Set @Event_name = Lookup('Event detail', 'Event_Name', 'Event_ID', @Event_ID)

]%%

Hello %%= v(@FirstName)=%%<br>
Thansk for watching %%= v(@Event_Name)=%%<br>

Here are more content you might be interested in<br>

%%[IF @Event_ID == '12345' THEN ]%%

    THANKS FOR WATCHING WEBINAR A 

%%[ELSEIF @Event_ID == '54321' THEN ]%%

    THANKS FOR WATCHING WEBINAR B 

%%[ELSE]%%

    THANKS FOR WATCHING WEBINAR C
                
    Thank you 

%%[ENDIF]%%
1

General pointer: Don't use IF / ELSEIF / ELSE here. This will only process one leg of the IF-statement so you cannot combine multiple. In other words: It's "either/or".

Solution 1)

You don't need "either/or", you need: "maybe A and maybe B and maybe C"

So: Just chain IFs.

Translated to pseudocode:

IF A THEN ... ENDIF; 
IF B THEN ...ENDIF; 
IF C THEN ...ENDIF;

Very simple, but very dumb, not elegant at all, hard to scale.


var @Subkey, @EmailAddress, @FirstName, @Event_ID, @Event_Name 

Set @Subkey = Subscriberkey 
Set @EmailAddress = EmailAddress
Set @FirstName = FirstName
Set @Event_ID = Lookup('event','Event_ID','Email_address',@EmailAddress)
Set @Event_name = Lookup('Event detail', 'Event_Name', 'Event_ID', @Event_ID)

]%%

Hello %%= v(@FirstName)=%%<br>
Thansk for watching %%= v(@Event_Name)=%%<br>

Here are more content you might be interested in<br>

%%[
IF @Event_ID == '12345' THEN 
]%%

    THANKS FOR WATCHING WEBINAR A 

%%[
ENDIF
IF @Event_ID == '54321' THEN 
]%%

    THANKS FOR WATCHING WEBINAR B 

%%[
ENDIF
IF @Event_ID == 'webinarC' THEN ]%%

    THANKS FOR WATCHING WEBINAR C
                
    Thank you 

%%[
ENDIF
]%%

Solution 2:

for loop. The "right" way to do this, short and concise, scales automatically with more records per person in your "event" table.

%%[ 
SET @EmailAddress = EmailAddress
Set @allAttendedEventsAsRowset = LookupRows('event','Email_address',@EmailAddress)
SET @rowCount = rowcount(@allAttendedEventsAsRowset)
 
IF @rowCount > 0 THEN
 
  FOR @i = 1 TO @rowCount DO
 
    SET @row = row(@allAttendedEventsAsRowset,@i) /*get row based on loop counter */
    SET @eventID = field(@row,'Event_ID')
    SET @eventName = Lookup('Event detail', 'Event_Name', 'Event_ID', @eventID)

]%%

THANKS FOR WATCHING %%=v(@eventName)=%%

%%[
 
  NEXT @i
 
ENDIF
]%% 

Code is from memory. Should work, but no guarantee. Hope it helps!

| improve this answer | |
  • Hello Jonas, Thanks for answering my question. I tried the first solution with multiple "IF" statements. Everything worked fine until i had those multiple statements such as " Event_ID == '12345' and Event_ID =='54321' then Thanks for watch A AND B. The second solution is actually what i am doing research on but i still have to test it out. – Bryce Mi Jul 23 at 16:29
0

I have slightly updated conditions that you have used, you can try out the below script and if it works make sure to mark as answered so this might help someone down the road.

%%[ var @Subkey, @EmailAddress, @FirstName, @Event_ID, @Event_Name

Set @Subkey =Subscriberkey 
Set @EmailAddress = EmailAddress 
Set @FirstName = FirstName 
Set @Event_ID = Lookup('event','Event_ID','Email_address',@EmailAddress) 
Set @Event_name = Lookup('Event detail', 'Event_Name', 'Event_ID', @Event_ID)

]%%


Hello %%= v(@FirstName)=%%
Thansk for watching %%= v(@Event_Name)=%%

Here are more content you might be interested in

%%[IF @Event_ID == '12345' THEN]%% THANKS FOR WATCHING WEBINAR A

%%[ELSEIF @Event_ID == '54321' THEN]%% THANKS FOR WATCHING WEBINAR B

%%[ELSEIF @Event_ID != '12345' or @Event_ID != '54321' THEN]%% THANKS FOR WATCHING WEBINAR C

%%[ENDIF]%%
| improve this answer | |
  • Hello Vinoth, Thanks for answering the question, but i am still having issue in this case. Fro example, one of the people in our Event table multiple records, so he attended A,B, AND C, So technically the logic should be %%[IF Event_ID == '12345' and Event_ID == '54321' and Event_ID == '135135' THEN]%% THANKS FOR WATCHING WEBINAR A AND B AND C , but it is juts not showing anything. sorry can put '@' in the code to comment for some reason. – Bryce Mi Jul 23 at 16:19

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.