ATG Personalization Programming Guide

Creating a Targeted E-mail Template

The page template for your targeted e-mail is specified by the templateURL property of the TemplateEmailInfoImpl object. You create this template like any other page. Because the template page is passed to the standard ATG servlet pipeline, it can include ATG servlet beans and additional JHTML or JSP tags.

Here is a sample JSP targeted e-mail template. It displays a few profile attributes and contains a targeting servlet bean. Assuming the targeting rules used in the TargetingForEach servlet bean’s targeter service depend on the attributes of the Profile component, the targeting results displayed in the e-mail message will be different for each profile.

<dsp:importbean bean="/atg/userprofiling/Profile"/>
<p>Dear <dsp:valueof bean="Profile.firstName"/>
<dsp:valueof bean="Profile.lastName"/>,
<p>Thank you for your order! It has been shipped today to:
<blockquote><pre>
<dsp:valueof bean="Profile.address"/><br>
<dsp:valueof bean="Profile.city"/>, <dsp:valueof bean="Profile.State"/>
<dsp:valueof bean="Profile.zipCode"/>
</pre></blockquote>
<p>Since your last order, we've introduced some great new products. If you enjoy
your new <dsp:valueof bean="Profile.lastProductShipped"/>, you may also be
interested in ordering some of these great widgets:<p>
<dsp:droplet name="/atg/targeting/TargetingForEach">
<dsp:param bean="/targeters/WidgetTargeter" name="targeter"/>
<dsp:oparam name="output">
<dsp:valueof param="element.name"/><br>
</dsp:oparam>
</dsp:droplet>
<p>Thank you for shopping with us.
<p>Sincerely,
The Customer Service Team
help@example.com
http://www.example.com

Here is the same example in JHTML:

<importbean bean="/atg/userprofiling/Profile">
<p>Dear <valueof bean="Profile.firstName"></valueof>
<valueof bean="Profile.lastName"></valueof>,
<p>Thank you for your order! It has been shipped today to:
<blockquote><pre>
<valueof bean="Profile.address"></valueof><br>
<valueof bean="Profile.city"></valueof>, <valueof bean="Profile.State"></valueof>
<valueof bean="Profile.zipCode"></valueof>
</pre></blockquote>
<p>Since your last order, we've introduced some great new products. If you enjoy
your new <valueof bean="Profile.lastProductShipped"></valueof>, you may also be
interested in ordering some of these great widgets:<p>
<droplet bean="/atg/targeting/TargetingForEach">
<param name="targeter" value="bean:/targeters/WidgetTargeter">
<oparam name="output">
<valueof param="element.name"></valueof><br>
</oparam>
</droplet>
<p>Thank you for shopping with us.
<p>Sincerely,
The Customer Service Team
help@example.com
http://www.example.com

Note that if your template page contains links to other URLs on your site, you must specify them as absolute URLs; otherwise the e-mail recipients will not be able to access the linked pages. Use the full http://server:port/... form of the URL. For example, in JSP code:

Specifying E-mail Fields in the Template

By default, the Personalization module takes the values for various fields of an e-mail message from properties of the TemplateEmailInfoImpl object. This behavior means that all messages using the same object will have identical properties. For example, suppose the value of the messageSubject property of the TemplateInfoImpl component is “Hello”. All e-mail messages created by this component will contain the subject line “Hello”.

You can override the values of these properties in a specific e-mail template by doing the following:

In the template, include parameters with the same names as the corresponding TemplateEmailInfoImpl properties.

Set the fillFromTemplate value of the TemplateEmailInfoImpl object to true.

For example, you can set a different subject line for a specific mailing by including a statement as follows in the template for that mailing:

JSP example:

<dsp:setvalue value="Your order has shipped" param="messageSubject"/>

JHTML example:

<setvalue param="messageSubject" value="Your order has shipped">

Because these parameters are evaluated for each message individually, they can include dynamic content. For example, you could set the message subject as follows.

There are seven parameters that you can use in this way to override the corresponding TemplateEmailInfoImpl properties:

mailingName

messageFrom,

messageTo

messageReplyTo

messageSubject

messageCc

messageBcc

You can use any combination of these parameters in an e-mail template; if any of these parameters is not set, the system uses the corresponding property value instead.

For example, you could globally set the messageCc property to Cc yourself, but you could override this property if you wanted to Cc or Bcc other people to make them aware of a particular e-mail campaign. The messageCc and messageBcc parameters are defined as a string of e-mail addresses separated by commas. For example, you could add the following lines to a template file.