0

I'm looking to swap out an image based on the Gender field I'm using in SFMC.

Essentially, I'd like to have a female image as default, then if the field Gender equals male, I'd like to swap them out to display that male image. I understand I can use an Lookup with AMPscript, but I'm unsure of the exact code that can do it. Any help would be greatly appreciated.

I've researched the below as an example, but unsure what needs to be swapped out.

> %%[
>     Var @count
>     Set @count = RowCount(LookupRows("Male", "YOUR_SUBSCRIBER_KEY_COLUMN", AttributeValue("_subscriberkey")))
> 
>     IF @count = 1 THEN ]%%
>    
> 
> <img src="maleImage.jpg" /> %%[ ELSE ]%% <img src="femaleImage.jpg" />
> %%[ ENDIF ]%%

1 Answer 1

1

You can simply use if/else statement to display HTML image block based on the Gender attribute value.

For example:

%%[
    set @gender = AttributeValue("Gender")
    if @gender == "male" then
]%%

<img src="maleImage.jpg"/>

%%[
    elseif @gender == "female" then
]%%

<img src="femaleImage.jpg"/>

%%[else]%%

<img src="YourFallbackImage.jpg"/>

%%[endif]%%
1
  • Thank you, that worked.
    – pamg30
    Mar 13 at 13:28

You must log in to answer this question.

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