|
|
Documentation Wiki > ExactTarget > Content > AMPscript > Getting Started With AMPscript > AMPscript 201
AMPscript 201From $1Table of contentsThis scenario contains information on the following aspects of using AMPscript:
The full AMPscript code for this email is shown below: %%[/* 201 */
Var @memid, @fname, @lname, @prefname, @address, @city, @state, @zip, @mempref, @plat, @ship
Set @memid = MemberID
Set @fname = FirstName
Set @lname = LastName
Set @prefname = PrefName
Set @address = Address
Set @zip = Zip
Set @city = Lookup("ShipTimes","city","zip",@zip)
Set @state = Lookup("ShipTimes","state","zip",@zip)
Set @mempref = MemPref
Set @plat = Plat
/* 201 */ ]%%%%[ if not empty(@prefname) then ]%%%%= v(@prefname) =%%%%[ else ]%%%%= v(@fname) =%%%%[ endif
]%%, below are your account detailsName
First Name:%%= v(@fname) =%%Last Name:%%= v(@lname) =%%
%%[ if not Empty(@prefname) then ]%%Preferred Name:%%= v(@prefname) =%%
%%[ endif ]%%Address
Address:%%= v(@address) =%%City:%%= v(@city) =%%
State:%%= v(@state) =%%Zip:%%= v(@zip) =%%
Member Preferences
Shopping Preference:%%= v(@mempref) =%%Platinum Member:%%[ if @plat == "N" then ]%%
%%= RedirectTo(Concat('http://example.com?s=',_subscriberkey)) =%%
Sign-Up %%[ else ]%%%%= v(@plat) =%%%%[ endif ]%%
This code is quite similar to the example shown in AMPscript 101, but notice a few important differences that add more functionality to the email sends. The Lookup() FunctionIn the section of AMPscript shown below, the values of two variables (@city and @state) are set by retrieving information from the ShipTimes data extension: Set @city = Lookup("ShipTimes","city","zip",@zip)
Set @state = Lookup("ShipTimes","state","zip",@zip)
The Lookup() function consults the ShipTimes data extension and looks for the city and state that correspond with the ZIP code value contained in the @zip variable. The function then assigns the applicable city or state to the variable.
Preferred Name If/Else StatementThe Preferred Name field involves two different if/else statements. The first statement determines whether or not the field is shown at all in the email. If there is no preferred name, the field is not included in the message. If there is a preferred name, both the field and the preferred name are included in the email. %%[ if not empty(@prefname) then ]%%%%= v(@prefname) =%%%%[ else ]%%%%= v(@fname) =%%%%[ endif]%% In the section of AMPscript shown below, the ExactTarget application will insert a subscriber's preferred name from the sendable data extension if one is available. If one is not available, then the application defaults to the customer's first name. The if statement looks for the preferred name and inserts it if it finds one. If not, the else statement puts in the first name. <strong>%%[ ifnot empty(@prefname) then ]%%%%= v(@prefname) =%%%%[ else ]%%%%= v(@fname) =%%%%[ endif ]%% </strong>, below are your account details
In the case of Christa Hirsch, the email send refers to the data extension shown above and inserts the preferred name of Chris into the email greeting.
In the case of Shea Winslow, the email greeting defaults to the first name because no preferred name is available.
Platinum Status If/Else StatementIn the section of AMPscript shown below, the application determines whether the subscriber is a Platinum member. If the subscriber hasn't joined the Platinum program yet, the email contains a link prompting the subscriber to sign up on a separate web page. If the subscriber is a Platinum number, the email confirms that status by displaying a capital Y. Platinum Member: <strong style="color: #000;">%%[ if @plat == "N" then ]%%<a href="%%= RedirectTo(Concat('http://example.com?s=',_subscriberkey)) =%%" alias="Platinum Sign-Up">Sign-Up</a>%%[ else ]%%%%= v(@plat) =%%%%[ endif ]%%</strong>
The AMPscript [ if @plat == "N" then ]%% %%= RedirectTo(Concat('http://example.com?s=',_subscriberkey)) then displays the link if and only if the variable is set to "N." Any other answer displays the value of the variable v(@plat) in the email. In the screenshots displayed above, the email sent to Shea Winslow shows the link because she is not a Platinum member. The email sent to Christa Hirsch displays a Y in that field because she is a Platinum member. This page was last updated by Ryan Williams on Thu, 22 Dec 2011 16:44:48 GMT. If you require assistance with the ExactTarget application, please contact Global Support. If you wish to send Ryan direct feedback, fill out the form below:
Tags: (Edit tags)
|
Powered by MindTouch 2010 |