1

I have an email template with a clickable image in it. The URL for that image is a landing page with parameters attached. The scope of the landing page is to capture the parameters from the URL and save the data in a Data Extension using WSProxy.

Here is the full code of the landing page:

<script runat="server">
  Platform.Load("Core","1.1.1");
  
  var deLog = DataExtension.Init('06D8E8FD-1796-473C-9634-EA5F732816A2'); // Evaluare comanda Log
  var prox = new Script.Util.WSProxy();
  
  function Update(OrderId, SubscriberKey, Email, ClientId, Response) {
    var updateDE = {
      CustomerKey: '8A439AF3-0829-49FF-A9B2-9E0D063120D5',
      Properties: [
        {
          Name: 'OrderId',
          Value: OrderId
        },
        {
          Name: 'SubscriberKey',
          Value: SubscriberKey
        },
        {
          Name: 'EmailAddress',
          Value: Email
        },
        {
          Name: 'ClientId',
          Value: ClientId
        },
        {
          Name: 'Rating',
          Value: Response
        },
        {
          Name: 'DataRating',
          Value: DateTime.SystemDateToLocalDate(Date.now())
        }
      ]
    };

    var options = { 
      SaveOptions: [{
        PropertyName: "*",
        SaveAction: "UpdateAdd"
      }]
    };

    var UpdateResponse = prox.updateItem('DataExtensionObject', updateDE, options);
    deLog.Rows.Add({Message: 'Update Response: ' + Platform.Function.Stringify(UpdateResponse)});
  }
  
  try{
</script>

%%[ 
VAR @Response, @OrderId, @DataRating, @SubscriberKey, @Email

SET @Response = RequestParameter('Response')
SET @SubscriberKey = RequestParameter('SubscriberKey')
SET @Email = RequestParameter('Email')
SET @OrderId = RequestParameter('OrderId')
SET @ClientId = RequestParameter('ClientId')
]%%

<script runat="server">
    var OrderId = Variable.GetValue("@OrderId");
    var SubscriberKey = Variable.GetValue("@SubscriberKey");
    var Email = Variable.GetValue("@Email");
    var ClientId = Variable.GetValue("@ClientId");
    var Response = Variable.GetValue("@Response");
    
    if(Response) {
      Update(OrderId, SubscriberKey, Email, ClientId, Response);
    } else {
      deLog.Rows.Add({Message: 'No Response found'});
    }
</script>
 
<br>OrderId: %%=v(@OrderId)=%%
<br>Subscriber Key: %%=v(@SubscriberKey)=%%
<br>Email Address: %%=v(@Email)=%%
<br>Response: %%=v(@Response)=%%
<br>ClientId: %%=v(@ClientId)=%%

<script runat="server">
  } catch(e) {
    // Redirect works by throwing an exception, so if it is inside a try it will always end up in the catch statement
    // The below code is a workaround to ignore that exception and only save in the Log DE the error we did not expect
    var desc = e.description;
    
    if(desc.indexOf("ExactTarget.OMM.AMPScriptRedirectException") > -1) {
      Platform.Response.Write(desc);
    } else {
      deLog.Rows.Add({Message: Platform.Function.Stringify(e)});
      Write(Platform.Function.Stringify(e));
    }
    
  }
</script>

The code works and the data is upserted in the Data Extension but the script runs more than once. Sometime twice and sometime thrice. Couldn't find any rule or reason behind it. Anyone knows why it runs more than once?

5
  • do you have this in both html and text version? they both compile separately
    – EazyE
    Aug 23 at 12:12
  • No. This is only in HTML
    – Alex
    Aug 23 at 12:35
  • Perhaps because of the image will be clicked more than once? The "click" can be done manually more than once. Sometimes also some bots will follow the link inside an email, for example to do security jobs automatically or to do a preview. Aug 23 at 13:17
  • Is this page being displayed as an image in the email (and being used similar to a tracking pixel) or is this the destination url? Aug 24 at 1:17
  • If its being used inside the email it is likely being hit on preprocess of the email as well as the initial build of the email in send queue and then again on each open that images load Aug 24 at 1:19
0

After some more testing I figure it out.

This behavior was identified only on Outlook, on Yahoo and Gmail it works as expected. Because we don't have the SSL enabled yet, the URL is under http format and Outlook has a security check in place. We expect for this behavior to disappear after we enable the SSL and change the URL to https format.

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.