0

I am sending recipients to a cloudpage from an email.

I have written conditional logic to pass through the values email_address or membernumber when a user clicks the link.

My code is giving me a 400 bad request. I would like to know what I'm doing wrong.

Note: email_address and membernumber fields exist in the sendable Data Extension

%%[
    VAR @url, @adviserEmail, @adviserMember

    SET @Email = AttributeValue("EMAIL_ADDRESS")
    SET @member_number = AttributeValue("MEMBER_NUMBER")

    IF NOT Empty(@Email) THEN
        SET @url = "%%=RedirectTo(CloudPagesURL(111,'EMAIL_ADDRESS',@Email))=%%"
    ELSEIF NOT Empty(@member_number) THEN
        SET @url = "%%=RedirectTo(CloudPagesURL(111,'MEMBER_NUMBER',@member_number))=%%"
    ENDIF
    ]%%

<a href="%%=v(@url)=%%"

1 Answer 1

1

Basically the @url output doesn't execute the code but give you the string since you set the @url variable as a string.

The correct way to do is setting the @url with CloudPagesURL function first then you put the AMPscript code in your HTML code line. Try something like this:

%%[
    VAR @url, @adviserEmail, @adviserMember

    SET @Email = AttributeValue("EMAIL_ADDRESS")
    SET @member_number = AttributeValue("MEMBER_NUMBER")

    IF NOT Empty(@Email) THEN
        SET @url = CloudPagesURL(111,'EMAIL_ADDRESS',@Email)
    ELSEIF NOT Empty(@member_number) THEN
        SET @url = CloudPagesURL(111,'MEMBER_NUMBER',@member_number)
    ENDIF
]%%

<a href="%%=RedirectTo(@url)=%%">Your CTA button</a>
1
  • Many thanks for your help! Jul 12, 2023 at 13:10

You must log in to answer this question.

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