Firstly, there's nothing wrong with your code syntax, although I would encourage you to declare your variables with the
VAR keyword (as doing so adds the variables to an internal dictionary).
There are a number of different reasons why the page would be returning an error (in your case, you would be seeing a generic 500 error). In some instances, you are able to 'catch' errors by wrapping the AMPscript block with an SSJS try/catch handler, but it won't work in your scenario (I've tried).
However, you can debug your code in Email Studio by making the following changes:
- Set the
@SubscriberKey value as a constant (for an existing Subscriber Key)
UPSERTDE (emails use a different function, but have the same arguments)
- Paste the code into a new email
- Preview the email.
When you preview the email, OMM should return some helpful errors explaining what the problem is (for example, the DE does not exist).
You can also test this without updating the function names (in step 2) and an error will still be returned, but you may need still to update the function names depending on the type of error.
Here's some sample modified code.
VAR @SubscriberKey, @Operation
SET @SubscriberKey = '1234'
SET @Operation = 'Unsubscribe'
IF @Operation == 'Unsubscribe' THEN