|
|
ScenariosFrom $1Table of contents
This document contains scenario information that demonstrates the use of AMPscript and functions. Scenario 1: Concerts in Your AreaThe information below demonstrates how to use AMPscript in conjunction with data extensions to send an email message to subscribers about concerts occuring in their area. The contents of the email depend on the subscriber's stated genre performances. Download a file containing the sample code for this scenario here. Data Extensions and RelationshipsThe marketer creates a data extension to contain information about upcoming concerts. Each concert has an associated genre, range of ticket prices, date, artist, venue, and city. Later, the marketer will create AMPscript to include this information in an email based on the subscriber's city and genre preferences. The marketer creates a webpage (such as a Web Collect or a Smart Capture form) where subscribers indicate their preferred music genres. The preferences are stored in the Customer_Genre_Preferences data extension. The Subscriber table contains the following data:
The Customer_Genre_Preferences data extension contains the following data:
The Upcoming_Shows data extension contains the following data:
AMPscriptThe following AMPscript appears in the body of the email. <html>
<body style="font-size: 12px;color: #000099; font-family: verdana;">
%%[ /* This is an AMPscript Comment */ ]%%
<p>Hi %%First Name%%,<br><br>
We want to tell you about upcoming shows in your area based on your favorite music genres. We think you are as stoked as we are to see great live music and wanted to pass the word on. Enjoy!<br><br>
</p>
<h3>Upcoming Shows in %%City%%</h3>
<br><br>
%%[
/* First we want to determine if the customer has any favorite genres stored. If not, we want to encourage them to create online */
/* Otherwise, we will loop through every genre we find */
var @rsgenre, @rowgenre, @rsshow, @rowshow, @countergenre, @countershow, @currentgenre
SET @rsgenre = LOOKUPROWS("Customer_Genre_Preferences", "Customer ID", [Customer ID])
]%%
%%[
if ROWCOUNT(@rsgenre) == 0 then
]%%
<h4>We see that you don't have any genres stored, please add them online to get the most relevant information sent to you next time!</h4>
<a href="http://music.example.com">Add My Genres</a>
%%[
else
/* Now we are going to loop through each customer's genre, and then use that and City to look up upcoming shows to display in a table */
/* if we find a genre, but no corresponding shows, we are not going to display anything for that genre */
]%%
%%[
for @countergenre = 1 to ROWCOUNT(@rsgenre) do
SET @currentgenre = FIELD(ROW(@rsgenre, @countergenre), "Genre Preference")
SET @rsshow = LOOKUPROWS("Upcoming_Shows", "City", City, "Genre", @currentgenre)
if ROWCOUNT(@rsshow) != 0 then ]%%
<h4>%%=CONCAT("Upcoming ", @currentgenre, " Shows")=%%</h4><br>
<table width="700px" style="border: 1 solid black; font-size: 10px;color: #000099; font-family: verdana;" cellpadding="2" cellspacing="0">
<tr style="font-size: 10px;color: #999999; font-family: verdana; font-weight: bold;">
<td>Date</td>
<td>Artist</td>
<td>Venue</td>
<td>Tickets</td>
<td>City</td>
</tr>
%%[
for @countershow = 1 to ROWCOUNT(@rsshow) do
SET @rowshow = ROW(@rsshow, @countershow)
/* Here we are setting alternating style for the row */
if MOD(@countershow, 2)== 0 and @countershow != 1 then
]%%
<tr style="background-color: #dcdcdc;">
%%[else]%%
<tr>
%%[endif]%%
<td>%%=FORMAT(FIELD(@rowshow, "Show Date"), "ddd, MMM d")=%%</td>
<td>%%=FIELD(@rowshow, "Artist")=%%</td>
<td>%%=FIELD(@rowshow, "Venue")=%%</td>
<td><a href="http://music.com?ConcertID=%%=FIELD(@rowshow, 'Concert ID')=%%">%%=CONCAT("From", FORMAT(FIELD(@rowshow, "Low Price"), "C2")," to ", FORMAT(FIELD(@rowshow, "High Price"), "C2"))=%%</a></td>
<td>%%=FIELD(@rowshow, "City")=%%</td>
<tr>
%%[
next @countershow
]%%
</table>
<br><br>
%%[
endif
]%%
%%[
next @countergenre
]%%
%%[
endif
]%%
<custom name="opencounter" type="tracking"><table cellpadding="2" cellspacing="0" width="600" ID="Table5" Border=0><tr><td><font face="verdana" size="1" color="#444444">This email was sent to: %%emailaddr%% <br><br><b>Email Sent By:</b> %%Member_Busname%%<br>%%Member_Addr%% %%Member_City%%, %%Member_State%%, %%Member_PostalCode%%, %%Member_Country%%<br><br></font></td></tr></table><a href="%%profile_center_url%%" alias="Update Profile">Update Profile</a>
</body>
</html>
OutputWhen the marketer sends the email, the application processes the code: For Angel Ruiz: Hi Angel, We want to tell you about upcoming shows in your area based on your favorite music genres. We think you are as stoked as we are to see great live music and wanted to pass the word on. Enjoy! Upcoming Shows in IndianapolisUpcoming Rock Shows
Upcoming Alt-Country Shows
Upcoming Indie Shows
For John Doe: Hi John, We want to tell you about upcoming shows in your area based on your favorite music genres. We think you are as stoked as we are to see great live music and wanted to pass the word on. Enjoy! Upcoming Shows in ChicagoUpcoming Folk Shows
Upcoming Rock Shows
Scenario 2: Suggested Car ListingsIn this example, a car broker wants to send a subscriber an email that includes a list of makes and models of cars that the subscriber might like based on the subscriber's stated preference as to type of car. The car broker creates an attribute for the subscriber to contain the subscriber's preference in car type. The broker populates the attribute with a survey. Data Extensions and RelationshipsThe car broker also creates a data extension that contains multiple makes and models of cars for each of the short list of types that the subscribers could choose in the survey. The car broker creates a data relationship to associate the car_preference attribute on the subscriber to the type column in the data extension. The subscriber table contains the following data:
The cars data extension contains the following data:
AMPscriptThe car broker includes the following AMPscript block in the body of the email: <html>
...
<table style= "border: 1px solid black">
%%[ /* Starting AMPscript */
/* Declaring variables */
var @rs, @row, @cntr
/* Looking up related cars by subscriber */
/* Using lookup rows function to return a rowset of related cars to use */
SET @rs = LookupRows("Cars", "Type", car_preference)
/* Looping through each record in the recordset */
for @cntr = 1 to RowCount(@rs) do
/* If there is a value in the row, output to HTML */
SET @row = Row(@rs, @cntr)
/*Ending script block here */ ]%%
%%=Field(@row, "Make")=%% %%=Field(@row, "Model")=%%
%%[ /* resuming script block here */
next @cntr
/*Ending script block */]%%
</table>
</html>
OutputWhen the car broker sends the email, the application processes the code: For Angel Ruiz
For John Doe
For Jane Doe
This page was last updated by Ryan Williams on Tue, 13 Dec 2011 13:51:28 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 |