0

I've developed a landing page with two submit buttons, CTA1 and CTA2. When a user clicks on CTA1, data should be updated/inserted into DE1. Similarly, clicking on CTA2 should update/insert data into DE1, but with a different row for each button. Both rows should have the same user, but with different CTA_Button values. I've set up two primary keys, II and CTA_Button. However, after the first submission, users encounter a '500 Internal server error' when attempting to resubmit the button value. Could you please assist with this issue?

%%[
 var @subscriberKey, @value, @email
  SET @subscriberKey = _subscriberkey 
  
  IF RequestParameter("submitted") == "true" THEN
        /* Retrieve form data */
        SET @value = RequestParameter("value")
        SET @identity_identifier = @subscriberKey /* Get Subscriber Key */
        SET @email = emailaddr /* Get Subscriber Email */
        SET @createdDate = Now()  /* Get current date and time */
        
        /* Lookup to check if the user exists in the Data Extension */
        SET @lookupRows = LookupRows('AT_Unsubcribe_Data', 'identity_identifier', @identity_identifier, 'CTA_Button', @value)
        SET @rowCount = RowCount(@lookupRows)
        
        IF @rowCount > 0 THEN
        /* User exists Update existing row with CTA1 value */
                Upsertdata('AT_Unsubcribe_Data', 1, 'identity_identifier', @identity_identifier, 'Email_Address', emailaddr, 'CTA_Button', @value, 'CreatedDate', @createdDate) 
        ELSE
        /* User doesn't exist, insert a new row */
        InsertData('AT_Unsubcribe_Data', 'identity_identifier', @identity_identifier, 'Email_Address', emailaddr, 'CTA_Button', @value, 'CreatedDate', @createdDate)
     ENDIF
     ]%%
    <meta http-equiv="refresh" content="0;url=https://at.iqos.com/de/">
    %%[
    ENDIF
    ]%%

%%[
 IF RequestParameter("unsub") == "true" THEN
 
  /* Retrieve form data */
        SET @value = RequestParameter("value")
        SET @identity_identifier = @subscriberKey /* Get Subscriber Key */
        SET @email = emailaddr /* Get Subscriber Email */
        SET @createdDate = Now()  /* Get current date and time */
        
         /* Lookup to check if the user exists in the Data Extension */
        SET @lookupRows = LookupRows('AT_Unsubcribe_Data', 'identity_identifier', @identity_identifier, 'CTA_Button', @value)
        SET @rowCount = RowCount(@lookupRows)
        
         IF @rowCount > 0 THEN
        /* User exists Update existing row with CTA1 value */
                Upsertdata('AT_Unsubcribe_Data', 1, 'identity_identifier', @identity_identifier, 'Email_Address', emailaddr, 'CTA_Button', @value, 'CreatedDate', @createdDate) 
        ELSE
        /* User doesn't exist, insert a new row */
        InsertData('AT_Unsubcribe_Data', 'identity_identifier', @identity_identifier, 'Email_Address', emailaddr, 'CTA_Button', @value, 'CreatedDate', @createdDate)
    ENDIF
    
 ////UNSUB CODE////

 ENDIF
]%%
    <!-- CTA Button 1 -->
<div class="container">
      
      <div align="center">
    <form method="post">
     <input type="hidden" name="submitted" value="true">
        <input type="hidden" name="value" value="Weiterhin_E_Mails_erhalten">
   
      <button type="submit" class="submit_btn btn " style="background-color:#34303D;border:1px solid #34303D;border-radius:45px;color:#ffffff;display:inline-block;font-family: ‘IQOS’, Noto Sans, sans-serif; font-weight:normal;line-height:30px;text-align:center;text-decoration:none;width:280px;-webkit-text-size-adjust:none;mso-hide:all;font-size:16px; padding: 10px 10px 10px 10px; cursor: pointer;">Weiterhin E-Mails erhalten:CTA1</button>
    </form>

  </div></div>
  
<div class="container">     
      
   <div style="padding-top: 30px;"></div>
  
    <div align="center">
       <form method="post">
     <input type="hidden" name="unsub" value="true">
        <input type="hidden" name="value" value="Jetzt_abmelden">
    <button type="submit" class="submit_btn btn " style="background-color:#ffffff;border:1px solid #34303D;border-radius:45px;color:#34303D;display:inline-block;font-family: ‘IQOS’, Noto Sans, sans-serif; font-weight:normal;line-height:30px;text-align:center;text-decoration:none;width:280px;-webkit-text-size-adjust:none;mso-hide:all;font-size:16px; padding: 10px 10px 10px 10px; cursor: pointer;">Jetzt abmelden:CTA2</button>
    </form>         
      </div>  
 </div>
1
  • if this: ////UNSUB CODE//// is part of your AMPscript code, it must fail at some point. That's a javascript comment, AMPscript only allows /**/ syntax Commented Mar 21 at 7:33

1 Answer 1

0

Seeing your script only errors when resubmitting, it makes me think the issue is related to the UpsertData() function.

Are 'identity_identifier' and 'CTA_Button' both primary keys in your data extension?

You write you want to add a different row for each button, which means you should be able to exist in the DE more than once with the same subscriberkey, i.e., all combinations of 'identity_identifier' and 'CTA_Button'.

Alternatively, if this is not the problem try to take out the upsert function, and see if you still get the error.

You must log in to answer this question.

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