I am trying to triggered the email send after submitting a form on cloud page, i have used triggered send DE and scripts to do that. the code is working fine and but data is not inserting into triggered send DE and also, email is not triggering to the person who has filled the form.

Here is the processing page code:


var @email,@name,@lang,@id,@ts,@tsDef,@ts_sub,@ts_statusCode,@ts_statusMsg,@errorCode
set @email=RequestParameter(’EmailAddress’)
set @name=RequestParameter(’Name’)
set @lang=RequestParameter(’language’)
set @id=RequestParameter(’SubscriberKey’)

SET @ts = CreateObject(“TriggeredSend”)
SET @tsDef = CreateObject(“TriggeredSendDefinition”)
SetObjectProperty(@tsDef, “CustomerKey”, “187754”)
SetObjectProperty(@ts, “TriggeredSendDefinition”, @tsDef)

SET @ts_sub = CreateObject(“Subscriber”)
SetObjectProperty(@ts_sub, “EmailAddress”,@email)
SetObjectProperty(@ts_sub, “SubscriberKey”,@id)
SetObjectProperty(@ts_sub, “Name”,@name)
SetObjectProperty(@ts_sub, “language”,@lang)
AddObjectArrayItem(@ts, “Subscribers”, @ts_sub)
SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)



I have written this code above the HTML tags starts.

Please help me with this.

1 Answer 1

  • Please be informed that the AMPscript and the SSJS code gets executed at MC servers; before it is rendered as HTML at client browser.
  • So even before you input details and submit the form, your code is trying to send trigger send.
  • Next thing I noticed your code has inconsistent IF THEN ENDIF code.
  • You must include a conditional execute code as below, out of which mainly handle the logic is
    <input name="submitted" type="hidden" value="true" />
    <input name="submitted" type="hidden" value="true" />

IF RequestParameter("submitted") == true THEN

\\ your triggger code


<!DOCTYPE html>
      <form action="%%=RequestParameter('PAGEURL')=%%" method="post">

\\your other form details

         <input type="text" name="email">
         <input name="submitted" type="hidden" value="true" />
         <input type="submit" value="Submit">

You must log in to answer this question.

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