top of page

Send Triggered Email via AMPscript

Updated: May 14, 2021

In this blog, we are going to see how we can send a SFMC triggered email via AMPscript and Triggered Sends.

Use Case:

Let's say if a customer has signed up with his basic information (Email Address, First Name & Last Name) in a form hosted in a cloud page and needs to send an email immediately from Marketing Cloud.

Create a Triggered Send Data extension:

  • Go to Email Studio --> Email --> Data extensions --> Create data extension

  • Select 'Standard Data extension'

  • In creation method, select 'create from template' and select 'TriggeredSendDataExtension'

  • Add few other attributes according to requirement as shown in the below screenshot:

Triggered Send DataExtension Template
Triggered Send DataExtension Template

Create a Triggered send UI In SFMC:

  • Go to Email Studio --> Email --> Interactions --> Triggered Sends

  • Select create and give a name for triggered email

  • Select the email which needs to be sent

  • Select the triggered data extension wherein the records needs to be added and select the all subscriber list to add the records in the same list.

  • Click on Save and select 'Start/Restart' to activate the triggered sends

Add AMPscript in Cloud Page:

Below is AMPscript code for Triggered email with simple form (view code snippet):

Code Review:

  • In order to create triggered send and triggered send definition, we need to use CreateObject function which is @ts ,@tsDef and @ts_sub.

  • We will specify the attributes of the Triggered Send object and the Subscriber object using SetObjectProperty function.

  • The AddObjectArrayItem function is used to add the object attributes, and everything is then passed into the InvokeCreate function which will trigger an email

  • In order to trigger an email, we would need to use the InvokeCreate function.

In Action:

Simple form for Demo:

On click of submit, you can see that the same records gets inserted into data extension and will receive an email immediately to the respective email address including first name and last name with personalization.

Records in Triggered Send Data Extension
Records in Triggered Send Data Extension

Happy Learning!

Hope now you have an idea on how to implement triggered sends in the SFMC cloud page.

Please feel free to leave your feedback/comment in case of any queries.

6,972 views9 comments

Recent Posts

See All
bottom of page