We've created a new automation feature that allows you to inform your target audience about new products, offers and other webpage updates. Once set up, campaigns based on XML (Extensible Markup Language) data inclusion generate email content automatically.
1. Prepare an HTML email template
First, you have to prepare an HTML template in which to enter the XML data file information.
<table bgcolor="#EEEEEE" cellpadding="0" cellspacing="0" style="width: 100%;"> <tbody> <tr> <td align="center" valign="top" width="100%"> <table align="center" bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" style="margin-top: 10px; margin-bottom: 10px; width: 600px;"> <tbody> <tr> <td bgcolor="#FFFFFF" style="font-size: 12px; color: #666666; line-height: 150%; font-family: Arial; text-align: left; padding: 20px;" valign="top" width="600"> <table cellpadding="0" cellspacing="0" style="width: 100%;"> <tbody> <tr> <td style="font-size: 12px; color: #666666; line-height: 1.5; font-family: Arial; padding-bottom: 20px;" valign="top" width="600"> <p style="margin: 0px; padding: 0px;"><span style="color: #88a017; font-size: 18px;">Lorem ipsum</span></p> <p style="margin: 0px; padding: 0px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ut risus id lacus rutrum lobortis. Suspendisse eget risus id sapien luctus pharetra eget sed metus.</p> </td> </tr> </tbody> </table> <table align="center" border="0" cellpadding="0" cellspacing="5" style="width: 100%;"> <tbody> <tr> <td align="center" style="font-size: 11px; font-family: Arial; color: #666666;">This email was sent from #[CAMPAIGN:SENDER_NAME]# to <a href="mailto:#[EMAIL]#" style="font-size: 11px; font-family: Arial; color: #4d749c;" target="_blank">#[EMAIL]#</a>.</td> </tr> <tr> <td align="center" style="font-size: 11px; font-family: Arial; color: #666666;">#[LIST:COMPANY]# | #[LIST:ADDRESS]#</td> </tr> <tr> <td align="center" style="font-size: 11px; font-family: Arial; color: #666666;"><a href="#[LIST:URL]#" style="font-size: 11px; font-family: Arial; color: #4d749c;" target="_blank">Why am I receiving this email?</a></td> </tr> <tr> <td align="center" style="font-size: 11px; font-family: Arial; color: #666666;"><a href="#[UNSUB]#" style="font-size: 11px; font-family: Arial; color: #4d749c;" target="_blank">Click here to unsubscribe</a> | <a href="#[UPDATE_PROFILE]#" style="font-size: 11px; font-family: Arial; color: #4d749c;" target="_blank">Update your profile</a> | <a href="#[FORWARD]#" style="font-size: 11px; font-family: Arial; color: #4d749c;" target="_blank">Forward to a friend</a></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table>
2. Prepare XML data The next step is to prepare XML data source. It must contain the data about your products in the website or any other information you wish to display in your email content.
5,- 8,93 44 http://www.somedomain.com/product-nr-1 http://www.somedomain.com/product-nr-1/image_name.jpg
9,90 30,- 67 http://www.somedomain.com/product-nr-2 http://www.somedomain.com/product-nr-2/image_name.jpg
17,90 33,15 46 http://www.somedomain.com/product-nr-3 http://www.somedomain.com/product-nr-3/image_name.jpg
3,90 10,- 61 http://www.somedomain.com/product-nr-4 http://www.somedomain.com/product-nr-4/image_name.jpg
3. Prepare HTML code for your XML data Prepare and format HTML code to suit your needs for displaying information about your products taken from XML data source.
#[XMLBLOCK01:URL=http://www.yourdomain.com/products.xml|LOOP_ELEMENT=product|ITEMS=3]# <h1>Category Name</h1> #[XMLITEMS]# <table border="0" cellpadding="0" cellspacing="0" style="padding: 0px; width: 100%;"> <tbody> <tr> <td style="padding: 10px 10px 10px 10px;" valign="top" width="150"> <img src="#[XMLITEM:image]#" border="0" alt="" width="150" height="150" style="display: block;"/> </td> <td style="padding: 10px 10px 10px 10px;" valign="top"> <h2>#[XMLITEM:description]#</h2> <p> Price: #[XMLITEM:price]#</p> <p> Discount: #[XMLITEM:discount]#</p> <a href="#[XMLITEM:url]#" style="color: #006699; text-decoration: none;"> read more </a> </td> </tr> </tbody> </table> #[/XMLITEMS]# #[/XMLBLOCK01]#
XML merge tag explanation in HTML code:
...... 5,- 8,93 44 http://www.somedomain.com/product-nr-1 http://www.somedomain.com/product-nr-1/image_name.jpg
4. Place prepared XML data HTML content into your HTML email template Now paste the product HTML content into your email template. This is how email template looks like in the end:
<table bgcolor="#EEEEEE" cellpadding="0" cellspacing="0" style="width: 100%;"> <tbody> <tr> <td valign="top" align="center" width="100%"> <table align="center" bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" style="margin-top: 10px; margin-bottom: 10px; width: 600px;"> <tbody> <tr> <td bgcolor="#FFFFFF" valign="top" style="font-size: 12px; color: #666666; line-height: 150%; font-family: Arial; text-align: left; padding: 20px;" width="600"> <table cellpadding="0" cellspacing="0" style="width: 100%;"> <tbody> <tr> <td valign="top" width="600" style="font-size: 12px; color: #666666; line-height: 1.5; font-family: Arial; padding-bottom: 20px;"> <p style="margin: 0px; padding: 0px;"><span style="color: #88a017; font-size: 18px;">Lorem ipsum</span></p> <p style="margin: 0px; padding: 0px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ut risus id lacus rutrum lobortis. Suspendisse eget risus id sapien luctus pharetra eget sed metus.</p> </td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" style="width: 100%;"> <tbody> <tr> <td valign="top" width="600" style="font-size: 12px; color: #666666; line-height: 1.5; font-family: Arial;"> #[XMLBLOCK01:URL=http://www.yourdomain.com/products.xml|LOOP_ELEMENT=product|ITEMS=3]# <h1>Category Name</h1> #[XMLITEMS]# <table border="0" cellpadding="0" cellspacing="0" style="padding: 0px; width: 100%;"> <tbody> <tr> <td style="padding: 10px 10px 10px 10px;" valign="top" width="150"> <img src="#[XMLITEM:image]#" border="0" alt="" width="150" height="150" style="display: block;"/> </td> <td style="padding: 10px 10px 10px 10px;" valign="top"> <h2>#[XMLITEM:description]#</h2> <p> Price: #[XMLITEM:price]#</p> <p> Discount: #[XMLITEM:discount]#</p> <a href="#[XMLITEM:url]#" style="color: #006699; text-decoration: none;"> read more </a> </td> </tr> </tbody> </table> #[/XMLITEMS]# #[/XMLBLOCK01]# </td> </tr> </tbody> </table> <table align="center" border="0" cellpadding="0" cellspacing="5" style="width: 100%;"> <tbody> <tr> <td style="font-size: 11px; font-family: Arial; color: #666666;" align="center">This email was sent from #[CAMPAIGN:SENDER_NAME]# to <a href="mailto:#[EMAIL]#" target="_blank" style="font-size: 11px; font-family: Arial; color: #4d749c;">#[EMAIL]#</a>.</td> </tr> <tr> <td style="font-size: 11px; font-family: Arial; color: #666666;" align="center">#[LIST:COMPANY]# | #[LIST:ADDRESS]#</td> </tr> <tr> <td style="font-size: 11px; font-family: Arial; color: #666666;" align="center"><a href="#[LIST:URL]#" target="_blank" style="font-size: 11px; font-family: Arial; color: #4d749c;">Why am I receiving this email?</a></td> </tr> <tr> <td style="font-size: 11px; font-family: Arial; color: #666666;" align="center"><a href="#[UNSUB]#" target="_blank" style="font-size: 11px; font-family: Arial; color: #4d749c;"> Click here to unsubscribe</a> | <a href="#[UPDATE_PROFILE]#" target="_blank" style="font-size: 11px; font-family: Arial; color: #4d749c;">Update your profile</a> | <a href="#[FORWARD]#" target="_blank" style="font-size: 11px; font-family: Arial; color: #4d749c;">Forward to a friend</a></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table>
5. Create and send emails based on XML The last step is to create and send your email campaign. Here is an example of how to do that using API functions :
$listId, 'subject' => 'Test Newsletter Subject', 'from_email' => 'example@example.org', 'from_name' => 'DEMO, Inc.', 'tracking' => array( 'opens' => true, 'html_clicks' => true, 'text_clicks' => false ), 'analytics' => array( 'google' => 'my_google_analytics_key' ), 'title' => 'Test Newsletter Title', 'generate_text' => true, //auto generate plain ); $content = array( 'html' => file_get_contents('xml-campaign-template.html'), ); $cid = $api->campaignCreate($type, $options, $content); header("Content-Type: text/plain"); if ($api->errorCode){ echo "Unable to load campaignCreate()!\n"; echo "\tCode=".$api->errorCode."\n"; echo "\tMsg=".$api->errorMessage."\n"; } else { echo "New Campaign ID:".$cid."\n"; //Send campaign $retval = $api->campaignSendNow($cid); if ($api->errorCode){ echo "Unable to load campaignSendNow()!\n"; echo "\tCode=".$api->errorCode."\n"; echo "\tMsg=".$api->errorMessage."\n"; } else { echo "Campaign Sent!\n"; } }
Here is an example of how your email campaign looks in the email clients of your subscribers: