0

I'm trying to trigger a "Triggered Send" from when a user clicks on a link in an email. At the moment I'm passing users through to a CloudPage, inserting their info into a Triggered Send DE and then trying to send them a triggered email that has the audience of the Triggered Send DE.

I'm getting a 500 error on the cloud page but I can see them being inserted into the DE. I assume my trigger code is incorrect.

Here is my code;

%%[
SET @customerId = RequestParameter('customerId')
SET @customerType = RequestParameter('customerType')
SET @Email = RequestParameter('Email')

IF @customerId != '' THEN

InsertDE('Welcome_Journey_Trigger','SubscriberKey', @customerId,'CustomerType', @customerType,'EmailAddress', @Email,)

SET @ts = CreateObject("TriggeredSend")
SET @tsDef = CreateObject("TriggeredSendDefinition")
SetObjectProperty(@tsDef, "CustomerKey", 5869) 
SetObjectProperty(@ts, "TriggeredSendDefinition", @tsDef)  
SET @ts_sub = CreateObject("Subscriber")
SetObjectProperty(@ts_sub, "EmailAddress", @Email)
SetObjectProperty(@ts_sub, "SubscriberKey", @Email)

SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)  

   IF @ts_statusCode != 'OK' THEN
       RaiseError(@ts_statusMsg, 0, @ts_statusCode, @errorCode)
   ENDIF

ENDIF
]%%

Any help would be greatly appreciated. Thanks.

  • No need to add a row to the trigger DE. That happens automatically when you trigger an email to a triggered send definition with a DE selected. – Adam Spriggs Jul 31 '18 at 17:06
  • Thanks for your response Adam. I have removed the "InsertDE" line but I still get a 500 error message. Anything else you can see wrong? – Kai Curtis Aug 1 '18 at 13:08
  • @KaiCurtis your customer key value should be in quotes "5869" – Noor Alam Aug 13 '18 at 10:35
1

Thanks Adam & Noor. Here is the final code that i eventually got working.

%%[
    SET @customerId = RequestParameter('customerId')
    SET @customerType = RequestParameter('customerType')
    SET @Email = RequestParameter('Email')

    SET @ts = CreateObject("TriggeredSend")
    SET @tsDef = CreateObject("TriggeredSendDefinition")
    SetObjectProperty(@tsDef, "CustomerKey", "5869") 
    SetObjectProperty(@ts, "TriggeredSendDefinition", @tsDef)  

    SET @ts_sub = CreateObject("Subscriber")
    SetObjectProperty(@ts_sub, "EmailAddress", @Email)
    SetObjectProperty(@ts_sub, "SubscriberKey", @customerId)

    SET @attr = CreateObject("Attribute")
    SetObjectProperty(@attr, "Name", "ChannelMemberID")
    SetObjectProperty(@attr, "Value", "100015131")
    AddObjectArrayItem(@ts_sub, "Attributes", @attr)

    SetObjectProperty(@attr, "Name", "CustomerType")
    SetObjectProperty(@attr, "Value", @customerType)
    AddObjectArrayItem(@ts_sub, "Attributes", @attr)
    AddObjectArrayItem(@ts, "Subscribers", @ts_sub)

    SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)  
       IF @ts_statusCode != 'OK' THEN
          RaiseError(@ts_statusMsg, 0, @ts_statusCode, @errorCode)
       ENDIF
    ENDIF
]%%

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.