In order to grab information from a data extension, there is one of two ways to go about this.
1. Using a non-Sendable Data Extension
When you use a non-sendable data extension, you need to individually lookup each item based on the current subscriber's email address, subscriber key, or some other identifier. Here is a code snippet that shows how this would work:
%%[
SET @rowset = LookupRows("Offers","EmailAddress", emailaddr)
SET @row = Row(@rowset, 1)
]%%
%%= Field(@row, "OfferImg")=%%<br>
%%= Field(@row, "LoyaltyID")=%%<br>
%%= Field(@row, "OfferDesc")=%%<br>
%%= Field(@row, "OfferSavings")=%%<br>
%%= Field(@row, "OfferURL")=%%<br>
You would get a @rowset
based on the identifier (in this case emailaddr
). You would then grab the first row (in most cases it's the first row, but not always). You would then grab the specific field from that particular @row
. @rowset
and @row
can be named anything, I'm using very literal variable names here. You grab each field using the Field()
function, passing in tow parameters, the row and the column name, like below:
%%= Field(@row, dataExtensionColumnName)=%%
2. Using a Sendable Data Extension
This simplifies your code quite a bit when you send an email to a sendable data extension. Each row in your sendable data extension should be unique in this case, as each row would be a new email that is sent. The same results as above would be produced with:
%%OfferImg%%<br>
%%LoyaltyID%%<br>
%%OfferDesc%%<br>
%%OfferSavings%%<br>
%%OfferURL%%<br>
Sendable data extension fields behave just like list attributes, so that personalization strings like the above code shows work. Note: Attributes take precedence here, meaning that if you have LoyaltyID
in your list attributes, and LoyaltyID
in your sendable data extension, the list attribute's LoyaltyID
would be the value used.