InsertDE
Inserts a new row into a data extension using ordered column/value pairs and returns an empty string. The email-context twin of InsertData — runtime-proven on a live Marketing Cloud Engagement CloudPage.
Syntax
InsertDE(dataExt, columnName1, valueToInsert1[, columnNameN, valueToInsertN, ...]) → string
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
dataExt |
string | Yes | Name or external key of the data extension to insert into |
columnName1 |
string | Yes | First column to write |
valueToInsert1 |
string | number | Yes | Value for the first column |
columnNameN |
string | No | Further columns, each paired with a value |
valueToInsertN |
string | number | No | Value for the corresponding further column |
Example
%%[
InsertDE("AMP_VERIFY_SCRATCH", "Id", "D1", "FirstName", "Dora", "Score", 3)
]%%
Renders nothing — InsertDE returns an empty string. Reading the row back in a later render confirms the write: rows=[1] FirstName=[Dora].
A realistic use inserts a row inside a send:
%%[
InsertDE("SendLog", "SubscriberKey", _subscriberkey, "SentAt", Now())
]%%
Return value
string — always an empty string, so nothing is emitted into the message. This is the only runtime difference from InsertData, which returns the inserted-row count. The *DE family is intended for email sends where you do not want a stray value printed; the *Data family is intended for CloudPages.
Behaviour
Ordered column/value pairs. Arguments after dataExt are read as column, value, column, value, … — identical to InsertData. The families differ only in the return value, not the argument shape.
Inserting a duplicate primary key aborts the page. A second insert with the same PK raises a runtime error that discards all output — guard with a prior Lookup or use UpsertDE.
Writes are not visible to same-render reads of a row already read. AMPscript caches data-extension row reads within a single render; confirm the insert in a subsequent render.
Show test script
%%[
VAR @b, @r
SET @b = RequestParameter("b")
IF @b == "zzz" THEN
OutputLine(Concat("CTRL=[alive]"))
ENDIF
IF @b == "safe" THEN
DeleteData("AMP_VERIFY_SCRATCH", "Id", "D1")
SET @r = InsertDE("AMP_VERIFY_SCRATCH", "Id", "D1", "FirstName", "Dora", "Score", 3)
OutputLine(Concat("InsertDE ret=[", @r, "]"))
ENDIF
IF @b == "read" THEN
OutputLine(Concat("D1 rows=[", RowCount(LookupRows("AMP_VERIFY_SCRATCH", "Id", "D1")), "] FirstName=[", Lookup("AMP_VERIFY_SCRATCH", "FirstName", "Id", "D1"), "]"))
ENDIF
]%%
OutputLine given a bare string literal renders an empty line. Wrap the argument in Concat() or your start and done markers vanish silently — which looks exactly like the function failing.
Availability
| Platform | Available |
|---|---|
| Marketing Cloud Engagement | Yes |
| Marketing Cloud Next | No |
See also
InsertData— the CloudPage twin; same arguments, returns the inserted-row countUpsertDE— insert or update in one callUpdateDE·DeleteDE- Official reference · ampscript.guide