AMPscript development
Personalised emails, SMS and CloudPages built with AMPscript that handles missing data gracefully and is readable by the next developer.

AMPscript is the scripting language that turns a Marketing Cloud Engagement email into a personalised one. It reads subscriber attributes, looks up rows in data extensions, builds conditional content and powers CloudPages such as preference centres. It is also unforgiving: a lookup that returns nothing, a date in an unexpected format or a null value in a function call can stop a send or render a broken message.
An experienced AMPscript developer writes code that expects imperfect data, stays readable and is tested against the real shapes of your data extensions.
What we build
- Dynamic email content driven by profile attributes, order history or product recommendations stored in data extensions.
- Conditional blocks for language, region, loyalty tier or lifecycle stage.
- CloudPages for preference centres, unsubscribe flows and simple forms that write back to data extensions.
- SMS and push message personalisation using the same data.
- Refactors of existing scripts that have grown long, slow or fragile.
An example of defensive AMPscript
The snippet below greets a subscriber by first name with a fallback, then reads their most recent order from a sample data extension. It assumes a data extension called Orders_DE with fields SubscriberKey, OrderNumber and OrderDate. It is a teaching example, not drop-in production code.
%%[
SET @firstName = AttributeValue("FirstName")
IF EMPTY(@firstName) THEN
SET @firstName = "there"
ENDIF
SET @rows = LookupOrderedRows("Orders_DE", 1, "OrderDate DESC", "SubscriberKey", _subscriberkey)
IF RowCount(@rows) > 0 THEN
SET @row = Row(@rows, 1)
SET @orderNumber = Field(@row, "OrderNumber")
SET @hasOrder = "true"
ELSE
SET @hasOrder = "false"
ENDIF
]%%
Hi %%=v(@firstName)=%%,
%%[ IF @hasOrder == "true" THEN ]%%
Thanks for order %%=v(@orderNumber)=%%.
%%[ ELSE ]%%
Here is what is new this month.
%%[ ENDIF ]%%Two habits matter here. AttributeValue returns an empty value instead of erroring when the attribute is missing, and the RowCount check prevents Row() being called on an empty rowset. For a fuller comparison of lookup functions, see AMPscript LookupRows vs LookupOrderedRows. When something breaks in a live send, How to Debug AMPscript Personalization Errors walks through the diagnosis, and the AMPscript Cheat Sheet keeps common functions to hand.
Problems we are often asked to fix
- Sends that error for some subscribers. Usually a lookup or date function receiving an empty or badly formatted value. We reproduce it with the affected records and add guards.
- Slow sends. Several lookups per subscriber across large data extensions add up. Moving the joins into SQL before the send often helps more than tuning the script.
- Copy-and-paste sprawl. The same logic repeated in dozens of emails, each slightly different. We consolidate it into shared content blocks so a fix happens once.
- Previews that look fine but live sends that do not. Preview subscribers often have complete data. Testing against deliberately incomplete records catches the difference.
How we deliver AMPscript work
- 01
Understand the data
We review the data extensions, field types and fill rates behind each personalisation rule, because most AMPscript bugs are really data problems.
- 02
Write the logic in plain English
Each rule is agreed as a short statement, such as show the loyalty block only when tier is Gold or Silver, before any code is written.
- 03
Build with fallbacks
Every lookup, date and attribute has a defined behaviour when the data is missing or unexpected.
- 04
Test across data shapes
We preview and test send against subscribers chosen to cover each branch, including empty and edge-case records.
- 05
Document and hand over
Code is commented, variables are named clearly and a short note explains where each data dependency comes from.
Deliverables
| Item | Description |
|---|---|
| Personalisation specification | The agreed rules for each dynamic element, in plain language |
| AMPscript code | Commented code in content blocks or templates, organised for reuse |
| Test matrix | The test subscribers used and the result for each branch |
| Troubleshooting notes | Known edge cases and how to diagnose them |
Questions we hear
Should we use AMPscript or Server-Side JavaScript?
Can you fix an email that fails to send because of a script error?
Do you build preference centres?
Is heavy AMPscript a performance problem?
Need an AMPscript developer?
Share the email or CloudPage you need built or fixed, and we will scope the work with you.




