Archive for the ‘Personalized Email’ Category

A Do-It-Yourself Email Remarketing Script for PHP

Friday, March 12th, 2010

We know why shoppers abandon carts and we also know that email remarketing is an effective way to lure some of those shoppers back to complete their purchase. But how can you try remarketing to users with abandoned carts without investing a lot of time and money?

Try a Simple PHP Remarketing Script

There are a lot of good reasons to implement a robust remarketing system but sometimes there’s beauty in simplicity, especially when you just want to try something out quickly to see how well it works. To that end, we present a simple PHP script to send remarketing emails to your shoppers when they abandon carts.

The Abandoned Carts Input File

This script reads a comma delimited text file that lists carts that are currently abandoned (your e-commerce software likely has a report that creates this report or you may need to bang out a quick SQL query to do it). The file contains one row for each abandoned cart with the first element of each row being the email address of the shopper the cart belongs to. After that comes the products that were left in the cart. For example:

shopper1@yahoo.com, Item1, Item2, Item3
shopper2@gmail.com, Item1
shopper3@hotmail.com, Item1, Item2

The Script That Uses the Input File to Send Email

The php script below then sends out a reminder email to each customer in the file that shows them which items are still in their carts. You can customize the from name and address, subject, and body of the email by editing the configuration section at the top of the script.


<?php

error_reporting(E_ALL ^ E_NOTICE);

////////////////////////////////
// Configuration
////////////////////////////////
$inputFilePath = "abandoned_carts.txt";
$delayBetweenEmails = 2; // in seconds
$from_email = "mystore@mystore.com";
$from_name = "MyStore";
$subject = "Don't let your cart expire!";
$messageBody =
"Hi there,

You left a few items in your cart last time you shopped with us:

{CART_CONTENTS}

Bad news! Your cart is about to expire! Now's your chance to snap up those awesome products. Just go to http://mystore.com/cart.php and finish your purchase in one easy step.

Thanks,
The MyStore team";

////////////////////////////////
// End of Configuration
////////////////////////////////

function getCSVValues($string, $separator=","){
$elements = explode($separator, $string);
for ($i = 0; $i < count($elements); $i++) {
$nquotes = substr_count($elements[$i], '"');
if ($nquotes %2 == 1) {
for ($j = $i+1; $j < count($elements); $j++) {
if (substr_count($elements[$j], '"') %2 == 1) { // Look for an odd-number of quotes
// Put the quoted string pieces back together again
array_splice($elements, $i, $j-$i+1,
implode($separator, array_slice($elements, $i, $j-$i+1)));
break;
}
}
}
if ($nquotes > 0) {
// Remove first and last quotes, then merge pairs of quotes
$qstr =& $elements[$i];
$qstr = substr_replace($qstr, ”, strpos($qstr, ‘”‘), 1);
$qstr = substr_replace($qstr, ”, strrpos($qstr, ‘”‘), 1);
$qstr = str_replace(’”"‘, ‘”‘, $qstr);
}
}
return $elements;
}

// Open the input file with all the abandoned cart info
$fh = fopen($inputFilePath, “r”);
if(!$fh){
echo “Can’t find input file.”;
exit(0);
}

// Iterate through each line of the file
$i = 0;
while($line = fgets($fh)){
$errors = array();
$message = $messageBody;

// Split the comma separated line into an array.
$cartContents = getCSVValues($line);

// First element of array is recipient email address
$recipient_email = array_shift($cartContents);

// Replace {CART_CONTENTS} in the message body with the cart’s contents
$cartContentsStr = “”;
foreach($cartContents as $cartItem) {
$cartContentsStr .= $cartItem . PHP_EOL;
}

$message = str_replace(”{CART_CONTENTS}”, $cartContentsStr, $message);

$headers = “From: $from_name <$from_email>“;
$headers .= PHP_EOL;
$headers .= “Reply-To: $from_email”;

mail($recipient_email,$subject,$message,$headers);

// Sleep for a bit so as not to overload the mail relay and get flagged
sleep($delayBetweenEmails);

$i++;
}

echo “$i emails successfully sent.”;

?>

To use this script, just copy and paste the above code into a file and save it as email_remarketing.php (or whatever) on your web server or a server with a php interpreter installed. Then add your abandoned carts report to the same location and call it abandoned_carts.txt. Browse to email_remarketing.php in a web browser and off it runs.

Some Caveats

There are a few things to keep in mind before using this script:

  • This script was made to be run on linux servers. It will work on Windows servers but you have to add some mail relay info to the script (learn how here)
  • This script sends only plain text email but you can tweak it to send HTML email if you like
  • You shouldn’t send too many emails at a time with this script, otherwise you’ll run the risk of having the emails marked as spam and/or your mail relay throttling your throughput. Limit it’s use to a few hundred a day tops
  • This is simple, simple, simple and doesn’t contain any real management or reporting functionality.

Using a simple php script to do email remarketing is not a sexy or glamorous solution to cart abandonment but it will let you test the waters quickly and see what kind of response it drives. If you like the results you see early on you can certainly add more functionality to the script or even consider building or buying a more advanced system.

Why Getting Email Marketing Right is so Important

Tuesday, February 24th, 2009

I often feel that email is the neglected step child of retail marketing. We’ve all seen the news articles and blog posts that tout sexier marketing trends like Twitter and mobile marketing. Many retailers have already jumped on the social media and company blog bandwagon and will spend months planning and implementing these changes on their website. Yet, I so often run into marketers that are willing to throw together a weekly sales email in an hour and blast the same message to their entire customer list.  Why? Well, my guess is they are underestimating the “response” they get from email. Catalogers are quick to argue that offline communications drive online purchases, but how is online communication driving offline sales?

Read Why Getting Email Marketing Right is so Important »

Importance of Coordinating Search and Targeted Email

Tuesday, February 3rd, 2009

I read a great blog post yesterday on why aligning your SEO and targeted email strategy is important to reducing your cost of new customer acquisition. Julie Batten’s Using Search and E-mail to Acquire Customers post at Clickz has some great info in it. I pulled out the following quotes that I thought were particularly interesting:

Read Importance of Coordinating Search and Targeted Email »

Variable Pricing-Based Email Marketing: 25% Less Customers Can Make you 22% More Profit

Monday, January 5th, 2009

I talked last time about how variable pricing is a great way to maintain your margins on sale items and I gave three general steps on how to perform variable pricing with email marketing. The gist is that each of your customers has a different value for your products and the key is to figure out how to get them each to pay closer to what they are actually willing to pay. The main takeaway is that you should give different sale discounts to different segments of your customers based on their behavior patterns - and the patterns of other customers like them - concerning discounted items. Today, I’ll take a look at the main arguments that companies have when it concerns variable pricing.

Read Variable Pricing-Based Email Marketing: 25% Less Customers Can Make you 22% More Profit »

Spamidays are here. Don’t be a contributor.

Thursday, December 4th, 2008

Lets face it, the barrage of emails during the holiday season ends up developing an impenetrable amount of noise for most email users.  According to my quick sentiment analysis (Twitter and Facebook) I would say that increased, non-targeted emailing has developed a new season that is not being taken too favorably. Being opportunistic I would like to offer a new term for the season: Spamidays.   Following suit with economists I would declare that Spamidays has already begun and, unlike our recession, has a definable end date, probably the second week of January.

What data supports my thoughts?  Your inbox is probably the biggest indicator but here are a couple of supportive tweets (selected out of about 2,000 from the last 2 days):

Have other Gmail user noticed an increase in SPAM in the last few days? 153 in a day is way more than what I usually get! Holiday SPAMMING?
CrazyKinux [Reply] [Profile]20:31

Holiday catalog spam & junk mail is piling up. You can practically feel the desperation of the retailers this year…so much paper & email.
crystallyn [Reply] [Profile]10:12

Ah, the holiday season. Filling everyone’s electronic in box with extra-special spam.
textualdeviant [Reply] [Profile]10:30

Interesting sentiment.   Last year year’s Spam Report also confirms an ever increasing tidal wave of email over the holiday season:

‘Tis the season to be jolly, but this month’s spam levels brought little cheer to anti-spam analysts.  Overall spam levels continued to increase, accounting for nearly three out of four emails in November. To put that growth trend into perspective, in May 2007 spam accounted for approximately 64 percent of all email traffic.  Symantect 2007 Spam Report

So I have labeled the obvious but how can you ensure your email campaigns are construed as valuable and assistive and not viewed as a contributor to Spamidays?: Read Spamidays are here. Don’t be a contributor. »

Surviving the Holidays: 5 Marketing Tips for Retailers

Tuesday, November 25th, 2008

With so many reports out there talking about why retailers are going to be taking such a hit this year, I thought it might be worthwhile to focus on the positive. The down economy has opened up several opportunities for retailers to try out new and interesting ways of reaching their customers.  I wanted to share a few of these with you.

Finding Customers Who Will Weather This Storm: Customer Segmentation in a Down Economy

Tuesday, November 11th, 2008

With today’s news peppered with articles about the possible demise of Circuit City, the sinking Dow, and the continued decline in consumer spending, many companies are concerned about how their customers are going to respond to the tough times ahead. Several online retailers are already going down the discount path to try and get customers to spend their money early– well before their credit dries up. I’m sure many of you have already been hit up like I have with numerous discounts from shops that don’t typically give discounts – I’ve been surprised by the recent emails I’ve received from the likes of JCrew, a company that never seems to discount their merchandise.

Read Finding Customers Who Will Weather This Storm: Customer Segmentation in a Down Economy »

Obama Leading in the Polls? Perhaps it’s Due to Better Marketing

Tuesday, November 4th, 2008

First things first, no matter who you support, I hope all of you have either gone out to vote today, or are planning to go out to vote. Although I’m usually not this dedicated, I woke up at 6:30 this morning to try and make it to the polls by 7. I was hoping I might be able to get their before the crowds, but by the time I got there at 6:55, the line was already two blocks long. I’ve voted at the same polling station for over 10 years now, and I have to admit that I’ve never seen such an incredible turn out for any election thus far. It took me about an hour to make it through, which was actually less than what I originally thought, but glad I beat the long lines I know will be there later this evening.

Read Obama Leading in the Polls? Perhaps it’s Due to Better Marketing »

Targeted Email Campaigns Only Way to Recapture Email ROI

Monday, October 27th, 2008

Though Kevin Hillstrom believes that the low variable cost is the real factor in the “killer ROI” that email affords multi-channel retailers, I would also mention that it’s low variable cost also contributes to the low amount of effort that retailers put into their email marketing. That is, retailers don’t put the money they should behind email because they view the low variable cost - and low marginal cost - as a license to spam. The way this manifests itself in the marketplace is that spending on email optimization technology trudges behind other technological spending like, say, search engine optimization (SE0).

Read Targeted Email Campaigns Only Way to Recapture Email ROI »

How many Customer Segments are Too Many?

Wednesday, October 22nd, 2008

Earlier this month Tim Parry argued the merits of micro-segmentation in a Multichannel Merchant article called Divide and Conquer.  The gist is that the more you can sub-divide your segments, the better you can target your message to each group resulting in higher response rates.

Read How many Customer Segments are Too Many? »