Skip to main content
Hi all. I'm not an Ampscript expert and unfortunately don't have time to become one :). My organization is changing platforms for email preference settings, and I have to update our email footers. Our email administrator would like to use an IF ELSE statement in the link to our new preference center, so that if the IF attribute for any reason failed to return a dynamic user-specific URL, the backup ELSE value would send to a user to the static URL for our preference center login page. I'm not an expert at creating IF ELSE statements, so I followed the lead of an IF ELSE salutation we use sometimes to produce this:

 

 

<a href="%%[ IF Length([Preference_Center_Link]) > 0 THEN ]%%Preference_Center_Link%%[ ELSE ]%%https://......../email.html%%[ ENDIF ]%%">

 

Is this proper Ampscript syntax, or is there a better way to do this? Any and all help would be greatly appreciated. --cg

 

 
3 answers
  1. Oct 14, 2020, 5:55 PM
    Hi Chris,

     

    Here you go, both should work:

     

    %%[IF Length(Preference_Center_Link) > 0 THEN SET @URL = Preference_Center_Link ELSE SET @URL = "http://www.google.co.uk" ENDIF]%%<a href="%%=RedirectTo(@URL)=%%">Click here</a>

     

    OR

     

    %%[IF Empty(Preference_Center_Link) == "False" THEN SET @URL = Preference_Center_Link ELSE SET @URL = "http://www.google.co.uk" ENDIF]%%<a href="%%=RedirectTo(@URL)=%%">Click here</a>
0/9000