0

I have 2 landing pages 1 for unsubscribe 1 for thank you page for unsubscribe. I want send subscriber to thank you page if they unsubscribe. But without checking the unsubscribe checkbox it's directly redirecting.

When I click on landing page URL it's directly redirecting with out performing on click. I tried removing on click function still it's redirecting directly also tried checking error code condition still no progress.If comment redirect code it's staying on the current page can someone help me resolve this?

Here is the code i am trying

<input type="submit" value="Submit" onclick="performAction()">
<script>
 function performAction(){
    if (document.getElementById('MasterUnsubscribeChk').checked){
      %%[
   SET @subkey = RequestParameter("EmailAddress")
  SET @email = RequestParameter("Subscriberkey")

        SET @ll_sub = CreateObject("Subscriber")
        SetObjectProperty(@ll_sub, "EmailAddress", @email)
        SetObjectProperty(@ll_sub, "SubscriberKey", @subkey)
        set @subscription = CreateObject("SubscriberList")
        //process_listid from your original email
        SetObjectProperty( @subscription, "ID", XXXX)
        SetObjectProperty( @subscription, "IDSpecified", "true" )
        SetObjectProperty( @subscription, "Status", "Unsubscribed" )
        SetObjectProperty( @subscription, "StatusSpecified", "true" )
        AddObjectArrayItem( @ll_sub, "Lists", @subscription )
        SET @ll_statusCode = InvokeUpdate(@ll_sub, @ll_statusMsg, @errorCode)
        IF @ll_statusCode != "OK" THEN
        RaiseError(@ll_statusMsg, 0, @ll_statusCode, @errorCode)
        Else        Redirect("https://pub.s4.exacttarget.com/xxxx")
        ENDIF
      ]%%
    }
    }
</script>
0

You are confusing server side and client side processing. Your form with the checkbox should post to the confirmation page. It's in the confirmation page that you place your AMPScript. It performs the unsubscription and, if successful, displays a message saying "done".

2
  • Thanks Andrew i seperated the amp script code from the html script it's working fine now Jul 19 '17 at 17:25
  • Good to her you're unstuck. Could you accept the answer, please?
    – Macca
    Jul 20 '17 at 15:08

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.