Server-Side JavaScript Concert in Your Area Scenario

This information demonstrates how to use server-side JavaScript in conjunction with data extensions to send an email message to subscribers about concerts occurring 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.

The marketer creates a data extension to contain information about upcoming concerts. Each concert includes an associated genre, range of ticket prices, date, artist, venue, and city. Later, the marketer will create server-side JavaScript to include this information in an email based on the subscriber's city and genre preferences.

The marketer creates a webpage where subscribers indicate their preferred music genres. The preferences are stored in the Customer_Genre_Preferences data extension.

The Subscriber table contains this data:

Email AddressCustomer IDFirst NameLast NameCity
ettest201@example.com201AngelRuizIndianapolis
ettest202@example.com202JohnDoeChicago

The Customer_Genre_Preferences data extension contains the following data:

Customer IDGenre
201Rock
201Alt Country
201Indie
202Pop
202Folk
202Rock

The Upcoming_Shows data extension contains this data:

Concert IDGenreLow PriceHigh PriceShow DateArtistVenueCity
101Rock354510/27/2007Band AVenue AIndianapolis
106Indie1537.510/6/2007Band BVenue BNew York
107Indie254011/15/2007Band CVenue CChicago
108Alt-Country2547.510/27/2007Band DVenue DIndianapolis
109Indie355010/30/2007Band EVenue ENew York
111Alt-Country153010/19/2007Band FVenue FChicago
112Indie3557.511/2/2007Band GVenue GIndianapolis
113Folk253511/6/2007Band HVenue HChicago
114Alt-Country153011/15/2007Band IVenue IIndianapolis
115Indie253510/27/2007Band JVenue JIndianapolis
116Alt-Country153010/30/2007Band KVenue KNew York
117Rock1537.510/21/2007Band LVenue LChicago
118Indie153010/19/2007Band MVenue MIndianapolis
119Indie254011/2/2007Band NVenue NNew York
120Alt-Country254011/6/2007Band OVenue OIndianapolis
121Indie3557/511/15/2007Band PVenue PChicago
122Indie153010/27/2007Band QVenue QChicago
123Rock253510/30/2007Band RVenue RIndianapolis
124Indie3557.510/21/2007Band SVenue SChicago
125Alt-Country2547.510/19/2007Band TVenue TChicago
126Alt-Country3557.511/2/2007Band UVenue UIndianapolis
127Indie253511/6/2007Band VVenue VChicago
128Indie153011/15/2007Band WVenue WChicago
129Rock3557.510/27/2007Band XVenue XNew York
130Rock254010/30/2007Band YVenue YChicago
131Indie2547.510/21/2007Band ZVenue ZNew York
132Pop3557.510/19/2007Band 0Venue 0Chicago
133Folk253511/2/2007Band 1Venue 1New York
138Indie355010/21/2007Band 2Venue 2Chicago
139Indie1537.510/29/2007Band 3Venue 3Indianapolis
140Alt-Country254011/2/2007Band 4Venue 4Chicago
141Pop253511/6/2007Band 5Venue 5Indianapolis
142Rock254011/15/2007Band 6Venue 6New York
143Rock254010/27/2007Band 7Venue 7Indianapolis
144Rock153010/30/2007Band 8Venue 8Chicago
145Alt-Country254010/21/2007Band 9Venue 9Chicago
146Rock355010/19/2007Band 10Venue 10Chicago
148Rock355011/6/2007Band 11Venue 11Indianapolis

This server-side JavaScript appears in the body of the email:

When 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 Indianapolis

Upcoming Rock Shows

DateArtistVenueTicketsCity
Sat, Oct 27Band AVenue AFrom $35.00 to $45.00Indianapolis
Tue, Oct 30Band RVenue RFrom $25.00 to $35.00Indianapolis
Sat, Oct 27Band 7Venue 7From $25.00 to $40.00Indianapolis
Tue, Nov 6Band 11Venue 11From $35.00 to $50.00Indianapolis

Upcoming Alt-Country Shows

DateArtistVenueTicketsCity
Sat, Oct 27Band DVenue DFrom $25 to $47.50Indianapolis
Thu, Nov 15Band IVenue IFrom $15.00 to $30.00Indianapolis
Tue, Nov 6Band OVenue OFrom $25.00 to $40.00Indianapolis
Fri, Nov 2Band UVenue UFrom $35.00 to $57.50Indianapolis

Upcoming Indie Shows

DateArtistVenueTicketsCity
Fri, Nov 2Band GVenue GFrom $35.00 to $57.50Indianapolis
Sat, Oct 27Band JVenue JFrom $25.00 to $35.00Indianapolis
Fri, Oct 19Band MVenue MFrom $15.00 to $30.00Indianapolis
Mon, Oct 29Band 3Venue 3From $15.00 to $37.50Indianapolis

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 Chicago

DateArtistVenueTicketsCity
Fri, Oct 19Band 0Venue 0From $35.00 to $57.50Chicago

Upcoming Pop Shows

Date Artist Venue Tickets City Fri, Oct 19 Band 0 Venue 0 From $35.00 to $57.50 Chicago Upcoming Folk Shows

DateArtistVenueTicketsCity
Fri, Oct 19Band 0Venue 0From $35.00 to $57.50Chicago

Upcoming Rock Shows

DateArtistVenueTicketsCity
Sat, Oct 27Band LVenue LFrom $15.00 to $37.50Chicago
Tue, Oct 30Band RVenue RFrom $25.00 to $35.00Chicago
Sat, Oct 27Band 7Venue 7From $25.00 to $40.00Chicago
Tue, Nov 6Band 11Venue 11From $35.00 to $50.00Chicago