We have the below AMPScript that works almost perfect. The only issue is when it fails to generate a unsubscribe link, it defaults to preference center URL. We have a custom unsubscribe managed outside of Marketing Cloud so the profile centre URL doesn't work. What do we need to update so that if the unsubscribe fails to generate it outputs our generic preferences page rather than the current dynamic unsub URL Eg: outputs URL https://website.com/preferences
Thanks Andy
%%[
VAR @globalPrefData, @Contact_ID, @emailID, @emailName, @prefCorName, @prefName, @firstName, @Greeting, @unsubscribeKey, @unsubscribeLink, @unsubscribeURL, @rowSet, @channelName
/* Global preferences data extension */
SET @globalPrefData = "SFReportGlobal"
/* Unsubscribe link without personal unsub key */
SET @unsubscribeLink = "https://website.com/EmailUnsubscribe?id="
SET @channelName = "Events"
SET @Contact_ID = _SubscriberKey
SET @emailID = _emailid
SET @emailName = emailname_
SET @prefCorName = IsNullDefault(Preferred_Correspondence_Name, "")
SET @prefName = IsNullDefault(Preferred_Name, "")
SET @firstName = IsNullDefault([First Name], "")
/* Greeting selection */
IF @prefCorName != "" THEN
SET @Greeting = ProperCase(Trim(@prefCorName))
ELSEIF @prefName != "" THEN
SET @Greeting = ProperCase(Trim(@prefName))
ELSE
SET @Greeting = ProperCase(Trim(@firstName))
ENDIF
/* Checking test SK */
IF Substring(@Contact_ID,1,3) != "005" THEN
SET @rowSet = LookupRows(@globalPrefData,"18 Digit SF ID",@Contact_ID,"Channel Preference Setting: ChannelPreference",@channelName)
/*New Code Starts here*/
set @count = RowCount(@Rowset)
if (@count > 0) then
/*New Code ends here*/
SET @unsubscribeKey = FIELD(ROW(@rowSet,1), "Unsubscribe Key")
SET @unsubscribeURL = Concat(@unsubscribeLink,@unsubscribeKey)
/*New Code Starts here*/
endif
/*New Code ends here*/
ELSE
SET @unsubscribeURL = profile_center_url
ENDIF
]%%