Skip to main content

Ampscript for Beginners




AMPscript is a scripting language that you can embed within HTML emails, text emails, landing pages, SMS messages, and push notifications from MobilePush. The system processes the script at the point where you include it in the message to render content on a subscriber-by-subscriber basis.
You use AMPscript to include information from your data extensions in your messages and to update data extensions with information from your landing pages.

Ampscript can be used to personalize the email to include the individuals information like first name. For this in your email include -

Dear %%first_name%%,

.....................

where first_name is the data extension field name.

Ampscript can also be used to in a landing page to interact with the web service SOAP API to create a triggered send.

%%[ var @emailaddr, @ts, @tsDef, @ts_subkey, @ts_sub, @ts_statusCode, @errorCode SET @emailaddr = "help@example.com" SET @ts = CreateObject("TriggeredSend") SET @tsDef = CreateObject("TriggeredSendDefinition") SET @ts_subkey = @emailaddr SetObjectProperty(@tsDef, "CustomerKey", "VolConfirm") SetObjectProperty(@ts, "TriggeredSendDefinition", @tsDef) SET @ts_sub = CreateObject("Subscriber") SetObjectProperty(@ts_sub, "EmailAddress", @emailaddr) IF NOT EMPTY(@ts_subkey) THEN SetObjectProperty(@ts_sub, "SubscriberKey", @ts_subkey) ELSE SetObjectProperty(@ts_sub, "SubscriberKey", @emailaddr) ENDIF 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 ]%%

You can also use Ampscript in Cloudpages inorder to insert/update data within data extensions.
This can be used for capturing new leads using cloudpages.

InsertDE("DE_NAME","EmailAddress", @emailAddress,"SubscriberKey", @subscriberKey)

UpdateDE("DE_NAME",1,"EmailAddress", @emailAddress, "FirstName", @newFirstName)

Ampscript In 10 Min Course:



Comments

Popular posts from this blog

File Drop Automation

There are two different ‘types’ of automations you can make inside of Automation Studio. They are the Scheduled Automation and the  File Drop Automation .  These automations trigger when a file is dropped in a FTP location. File Drop Automation includes below options - Use File name pattern Similar to LIKE in SQL, the file name pattern looks for string in the file name.  Eg. '%abc%' No File name pattern If you set it to run on all files (no filename pattern), this will ‘lock’ that folder and will not allow any other file automations to select this folder.  It is not recommended to use the Import or Export folders  for this activity, but to instead create custom subdirectories for these automations.

Send Classification, Sender Profile and Delivery Profile Difference

Send classifications include these components: Delivery Profile Sender Profile You create the delivery profile and sender profile separately before you create the send classification.  Sender Profile A sender profile within Marketing Cloud Setup specifies the From information for a send in a central location. Marketing Cloud Email reuses that information across multiple sends without requiring selection each time. The sender profile contains the name and address that the message appears to be from in the subscriber's email client. Delivery Profile A delivery profile within Marketing Cloud Setup specifies the delivery information for a message in a central location. Marketing Cloud reuses the information, across multiple sends, without requiring selection of the information each time. When you create a delivery profile, specify the IP address to use. If you do not use a private domain, you select the account default. If you use one or more private domains, you can select the privat...

SFMC Daily #1: 5 SFMC Interview Questions for Today

Welcome to SFMC Daily.  SFMC Daily is a short blog of 5 Q/A which will help you keep up to date with your SFMC Interviews. Lets solve the SFMC Puzzel with Astro !!! Q- How does Dynamic Email work? You can define a dynamic content block in an email to display (render) information based on the subscriber’s attributes, data extension values, or audiences. Two ways: 1.    you can build a dynamic content block adding rules by point and click in email editor 2. using ampscript if else as well we can achieve this. Q- Name the entry sources in Journey Builder. Journey Builder Entry Sources include: Data Extension : contacts in a sendable data extension (the most commonly used). Salesforce Data:  contacts are added to the entry source, driven by something happening in Salesforce (eg. a record being created or updated). Audience:  if you’re using Audience Builder to create and publish audiences. Event:  for date-based events (eg. birthdays, anniversaries, reminders, ...