You probably know this: urgency and scarcity both
All these entrepreneurs opening their online course for a limited time only, all those « limited time discounts » you can find all over the web... They are all there to add urgency to their offers and make you act NOW. Your time is limited. Go. Get. The. Offer. Or it disappears forever.
Anyway, amongst these limited time discounts you'll find two types:
- the type where urgency is real: most often it’s entrepreneurs with a decent mailing list who can actually employ this technique to send to their existing audience and leverage that urgency to make sales
- the type where it’s complete bullshit and there’s no urgency whatsoever, if you come back months after you can still find the same landing page with the same « expires tomorrow » message blinking restlessly
This Post Will Disappear In...
Fake countdown, fake scarcity...
Today, we’re going to see how to create real urgency by leaving 5 days to your subscriber to take action and buy your product while building your audience.
Let’s get started.
Origin of the story
Some of my clients come to me with a product but no audience.
I’ve done it too. Guilty.
Ideally you have an audience first. You understand them and know what they really want so you can sell it to them.
But if you have a great product — and a fit with your market / audience — it’s no big deal: you can start acquiring
So how do you put urgency in your mailing sequence? How do you manage to say to a specific customer « Hey you’ve got 5 days to take action on this or you won’t get the discount again » while using relative time? Meaning 5 days from the day he receives the email, not a specific day on your calendar...
I wanted to be able to leverage scarcity and urgency while building a list from scratch.
So with this problem in mind, I took a day off to figure out the best approach.
What You'll Need
SPECIAL NOTE ABOUT ZAPIER
If you have a Web Developer or a Tech savvy guy in your contacts, just send him the link to this article, you’re set.
If you want to do this yourself, you’ll need:
- FTP access to your web server
- ActiveCampaign or an email marketing platform that allows you to post webhooks
- WooCommerce with the REST API enabled
I strongly recommend ActiveCampaign on this one, it’s really cheap to get started and there are a lot of automation features that other software lack (adding tags for instance). Way cheaper than InfusionSoft and I’ve heard InfusionSoft is pretty tough to handle at first... Not the case for ActiveCampaign.
Anyway, my code is written to work with ActiveCampaign but as long as you can post web hooks with your email automation software, you’re good to go — you will probably have to tweak the first part of my script to extract the subscriber data though.
Step by step guide on creating real urgency on autopilot
Here’s what we’re going to do:
- Each time an email subscriber enters a specific step of the sales funnel — you chose the trigger, in this particular project it’s email #3 of the sales email sequence — start the following process
- Create a user specific coupon — using the subscriber’s email — that expires in X days (your urgency delay) on your WooCommerce platform
- Email the subscriber about the limited time offer
First, let’s create a WooCommerce API access (and make sure everything is activated).
- Log into your WordPress dashboard
- Go to WooCommerce > Settings > API tab
- Make sure "Enable REST API" is checked
- Click on the Key / Apps sub menu
- Click on Add Key
- Set the permission to Write
- Enter a description if you feel the need to
- Click on Generate API Key
- Save the keys, you'll need them
Save that stuff...
Then, let’s create an automation workflow in ActiveCampaign.
- Log into your ActiveCampaign Account
- Go into the Automations tab and setup your workflow
My ActiveCampaign Workflow
Right before the last email (Time Sensitive Offer) we need to create a coupon that will expire after the duration of the discount.
This is what happens on the "Magic Trick" line. I use a webhook.
- Add an action in your automation workflow by clicking on the cicled + d
- Click on the Conditions & Workflow vertical tab
- Select Webhook and enter http://yoursite.com/coupon-gen/coupon-generator.php?key=temporary
Create a webhook in ActiveCampaign
We are basically saying to Active Campaign to post the subscriber's data to a PHP script on your server.
Said PHP script has the following mission:
- get the subscriber's email
- create a user specific discount coupon (with the value you want)
- that expires in the desired number of days
First, you need to download the WooCommerce API client here. Then I suggest you clean up the directory of all useless things (delete the examples folder, …) and add the following piece of code in a new file I call coupon-generator.php
And here it is:
To make it work for you you need to:
- You need to replace the key variable value by what you've put in your
webhook ( "temporary" if you've followed the steps), you can change it to something more secure and change thewebhook in Active Campaign - You need to replace the WooCommerce keys by those you've generated earlier following the step by step process
- You might need to change the coupons parameters and the expiry delay for your limited time offer (set to 5 days in the script above)
A NOTE ABOUT SECURITY
It’s worth mentioning a couple of things about security:
- stakes are not that high because even if someone manage to generate coupons, well he’s still going to buy your product at a discounted rate you were prepared to offer
- I’ve added a « key » variable that you should change. You’ll need to change the URL in ActiveCampaign accordingly http://yourwebsite.com/coupon-gen/coupon-generator.php?key=YOURPASSKEYHERE
- you can also change the name of the folder and the PHP file to obfuscate everything. Make just sure you propagate those changes to the web hook url in ActiveCampaign too
I’m sure we could figure out something a bit more complex, but this should do the trick (as always if you have a suggestion for a smarter solution, use the comments below).
You can have fun with the coupon parameters — the WooCommerce API documentation is available here — to customize then however you want.
You’ll note that I use the subscriber’s email as a coupon code and usage limitation. The restriction is for obvious security reasons — to limit the use of the discount — and the coupon code is just because I don’t want duplicate codes and needed an easy way to explain how to get the discount in the emails… « Just use your email in the coupon field » is easy enough for me ;)
If you generate a custom coupon code, you need a way to put it back in the email you’re sending for the promotion. I just thought the simpler the better.
Let's recap
So now, what happens?
Each time your subscriber reach that step before getting an email about the time sensitive offer, ActiveCampaign will send his or her info to the PHP script which will in turn create a WooCommerce coupon. The code of the coupon will be the subscriber’s email, it will expire in the number of days you’ve set and will be limited to his email address.
A smart thing to do will be to remember your subscriber the day before the discount ends in case they forgot — and you can use ActiveCampaign’s Tags to make sure they didn’t purchase before spamming them again.
As always, feel free to use the comments if you have questions, happy to help.
Want this on your WooCommerce?
I’m kind of scouting the interest for a specific plugin to do that for you without having to do some custom PHP or get out of WordPress, so let me know in the comments if this is something you’d like to see available online.
Update: since writing this post, other solutions have popped up online. If I were to work something out right now, I would check out Thrive Ultimatum which should handle everything you need — and more, friends have had amazing results with it.
Hi,
Did you get around to creating a custom plugin by the way? Happy to pay for one to make it all easier.
Dale.
Hey Dale, glad you stopped by :)
Nope, no plugin because of very little demand (let’s be totally honest: you’re the first ;)). Plugin development makes sense if there’s a lot of demand imo (because of all that will follow like support, integrating with other autoresponders, etc.).
Now, this process was developed before Zapier’s Multi Steps Zaps were released so I can make it simpler (no script outside Zapier or your site, etc.) What’s your setup? If you want we can chat about it (you can use the booking forms, consultations are open for March now [and Free] ).
Have a great Sunday!
Thank you for writing this article!
How to customize this line of code to only add ‘free shipping’ to the coupon and make it work for all the products on my website?
print_r( $client->coupons->create( array( ‘code’ => $user_email, ‘type’ => ‘percent’, ‘amount’ => 20, ‘individual_use’ => true, ‘product_ids’ => [3639,3637,3486], ‘usage_limit’ => 1, ‘usage_limit_per_user’ => 1, ‘expiry_date’ => $coupon_expiry, ‘description’ => ‘Temporary coupon generated for ‘ . $user_email, ‘customer_emails’ => $user_email) ) );
Maybe it is a good idea to make it easier for the customer to prefill the code after clicking on the link in the e-mail. That way the customer does not have to fill in the coupon code. I think this can increase conversion. Combine this script with https://www.woothemes.com/products/url-coupons/
Hi Sander, glad you liked the article!
1/ Didn’t try it live but I would set ‘amount’ => 0, remove the ‘product_ids’ property (to be store-wide) and add ‘enable_free_shipping’ => True in the code above. This should create a coupon that will enable free shipping, assigned to your subscriber email but store-wide.
2/ YES! I like the idea of reducing friction, especially using this plugin, you’ll be able to put a CTA directly to your checkout page in your email. Using this plugin, you can just link to your product using the email as a coupon: something like : mystore.com/coupon/your%40subscriber (note the @ transformed into %40)
Thanks for the input! Hope this helps,
Thomas
It works. :)
Maybe there’s an autofill plugin that will fill the coupon field via url.
mystore.com/[email protected]
That way I can put this in the ActiveCampaign autoresponder:
mystore.com/coupon?q=%EMAIL%
One question: is it possible to set this to hours instead of days?
$expiry_date = strtotime(“+2 day”);
It would be very nice if it can be hours. Because that way I can mail my customer exactly 1 hour before the coupon is expiring. Do you know how to do that?
Well, the plugin you talked about (and I’ve replied on 2/) is doing just this, as the coupon name is the email this should work. The @ shouldn’t be a problem (worth testing it to be sure though).
As for the hours, I looked into the source, the $expiry_date is compared against a timestamp so you have a lot of flexibility there. You can create dates & time as long as it’s in PHP format (line 386 here: https://docs.woothemes.com/wc-apidocs/source-class-WC_Coupon.html#27 ). I’m sure you thought of this but 24 hours = 1 day, and make sure you give enough time for them to take action, 24 hours might be a bit short if you have different timezones in your lists.
Most of the info I give you are from this resource:
https://docs.woothemes.com/wc-apidocs/class-WC_Coupon.html
Hope this helps!
Thanks for all your help with those docs. I’ll take a look at it.
I see you have also this url in your script: https://www.wed-u.com Do I need to change that also to my own URL?
I’m not a developer, so for me this is really copy, paste, trial and error. So I have to test with the time of the server or time of the WP installation, and the time of ActiveCampaign.
Okay I’ll try
$expiry_date = strtotime(“+24 hours”);
I hope this will work.
What I want is for example someone signs up in Paris today at 16:00, and tomorrow at 16:00 the coupon is expiring, and tomorrow at 15:00 the person will get an e-mail from ActiveCampaign to remember about the coupon.
So right now in Europe it’s 15:24 as I’m writing this, and in New York City it’s 09:24.
At this moment someone in New York signs up, right there it is 9:24 and after 24 the coupon will expire. And tomorrow at 8:24 that person will get an email from ActiveCampaign to remember about the expiring coupon.
So for me it is trial and error time right now. :) Thanks for your help, really appreciate that.
No Wed-U is a client ;) I’ve cleaned up the code.
I was talking about timezones for a different reason: everything is in relative time so you won’t have issues with what you’ve described. It’ll be 1 day after user sign up no matter where he is.
I was talking about timezones because sometime people sign up late at night using their smartphone and can’t really make a purchase in a 24h window (life gets in the way). If you’re sending all your email at 9am UT for instance, it might be problematic because if you have people on the US West Coast, they’ll have less than 24 hours because they won’t READ the email until they’re awake. Anyway, digressing.
You should try strtotime(‘+1 day’); rather than 24 hours if you want to tweak my code. Also, you might find good deals on platforms like Upwork to help you with this. This article contains enough info for an entry level PHP dev to take care of this for you ;)
Great article Thomas ! Thats exactly what i need but im using mailchimp. I really cant change your php code by myself. Is it possible for you to add it to your post for those using mailchimp ? Thx ;)
Hey Mehdi, glad you enjoyed the article. Thanks for stopping by!
After researching a tiny bit, it looks like MailChimp allows webhooks in specific cases: https://apidocs.mailchimp.com/webhooks/
You’ll have less control than with ActiveCampaign but you might be able to play with this.
As for the code modifications, you don’t have to change a lot, just this bit:
// Catch Hook from ActiveCampaign & basic security check if ($_POST['contact'] && ($_GET['key'] == $key)) { $user_email = $_POST['contact']['email'];
to:
if ($_POST['data'] && ($_GET['key'] == $key)) { $user_email = $_POST['data']['email'];
Might need some tweaking but it should work (basically the array sent by MailChimp is a bit different than the one sent by ActiveCampaign more info on the MailChimp API link above).
I have a lot of work on my plate right now and doing a complete update would take me a lot of time (especially testing it with MailChimp) but if there’s a lot of interest here I’ll update or fork this article and make a MailChimp version ;)
Hope this helps!
Many thx for your help here Thomas !
You’re welcome!
This is exactly what I’m looking for and am trying to make it work. However, the line in the article for the code “And here it is…” There’s no code there, what do I put in the coupon-generator.php file?
Please, please make a plugin.
Hey Randy, thanks a lot for your comment!
I fixed the script display you can now access it on the post :)
As for the plugin, I don’t really have the time right now to build it but happy to assist in the comment section (or if it gets too techy / with infos you don’t want to share) I’ll give you my email so you can make it work ;)
Let me know how it goes!
Hi Thomas, Thanks for the reply. I finally got time to start giving this a try. I’ve gone through all the instructions, but am not clear as to what to put in the email to send the ‘temporary offer’ …how to get the offer back into the email following the ‘magic trick’
I figured it out. I missed seeing a whole line of the code.
Not sure: did you sort it out? Sounds like yes at the end but also sounds like code don’t address your remark about your email content.
Basically: once you’ve generated the coupon with the magic trick, just add an email to your workflow and send it to your subscriber (explaining that the code is his email for the duration you’ve set).
So it wasn’t working. I checked the error log, and discovered this error message…
Unable to load dynamic library …/imagick.so. Found out it wasn’t installed on my hosting account. (I’m running a VPS account), so I had it installed.
Did another test today. no more error messages in the error.log file, but the coupon in WooCommerce wasn’t created.
Hard to know what doesn’t work from here. Did you generate and change the API keys and website URL from the script?
Yes I did, if you like, send me an email to randy at randydueck.com and I can email you the script, and my site logins for you to take a look and see where things are going wrong.
Following up by email :)
Did you get this working in Zapier? I’d love to do something similar but my coding skills aren’t up to scratch just yet
Hey Jacob, I didn’t rework it using Zapier. I think it should be possible now with the multi-step but it will still involve a lot of coding inside the actions.
You don’t have that much coding to do if you follow this article step by step (merely copy / paste and replace).
Can I improve the phrasing or process described so you can implement this easily? (where do you need more guidance?)
Howdy,
i read all the comments and im still not sure if i understand correctly –
at the moment of the magic trick in the activecampaign automation, the e-mail is sent by that script,
and i just e-mail my customer and say that look for the coupon code in that other e-mail that the system sent?
Isnt it possible to use the created coupon code like a variable in the upcoming e-mails?
Regards,
Gabriel
Hey Gabriel,
Sorry it’s so confusing. Basically, the coupon IS the email of the user so you can definitely use your subscriber’s email as the “coupon variable” to customize your copy.
The other trick the system does is set a real (and relative) urgency in place.
I’ve also seen new plugins and tools since I’ve wrote this piece of code : I’ve seen Bennan Dunn use Drip here : https://www.getdrip.com/university/brennan-dunn-drip-workshop/ and I’ve also seen (although didn’t test) some cool stuff from ThriveThemes and their Thrive Ultimatum plugin.
Hope this helps!
Does this works latest REST API?
I can’t seem to automate the coupon generation.
I placed the Woocommerce REST API file in my ~themes/mythemes/woocommerce/ path.
Added the coupon-generator.php.
Tried this too http://yourwebsite.com/coupon-generator.php but doesn’t work
Hey LSS, I haven’t tested this out in a some time, however the code should hold up pretty well. I’ve discovered other resources that you might like and could help you achieving what I do here, with less code: Thrive Ultimatum ( https://thrivethemes.com/ultimatum/ ) and Brennan Dunn’s approach using Drip ( https://www.getdrip.com/university/brennan-dunn-drip-workshop/ ). This last link gets a little bit techy though.
Hope this helps!
This is awesome, implanting this now. Hope this still works, a true gem.
I got a copy of Thrive Ultimatum but requested a refund. The thing is that it doesn’t play nice iwth WooCommerce. (if user adds to cart, you need to setup cron jobs otherwise after the dealdine the user can still access /checkout)
Def not working anymore :(. Thinking about how I can get this to work using Zapier.
EDIT: I take back my words, this does work 14/06/2017! Just follow instructions closely and read through the code, it turns out I didn’t add my domain at WC_API_Client
Hey Chris, excellent :) Glad the script still works, I hope it helps you in your project!
Hehe, it definitely helped. I switched to ThriveCart, I’m sick of WooCommerce. To many tweaks behind the scenes to make stuff happen :)
Nice recommendation, I’ll give it a try, thanks ;)
I had a look at Thrive Ultimatum like you suggest at the end of this post, but it seems you can only trigger a discount campaign when a user clicks a link inside the email.
You can’t trigger a discount campaign at a specific point within the email automation – that can only be done using your webhook method above.
I don’t want users to know they can wait around before clicking the link which activates their count down timer. The whole point is to create urgency and send them an email saying “This deal will expire in 24 hours so click this link and buy now before it’s too late”. But Thrive Ultimatum only starts the count down clock once a link is clicked, so it’s teaching them to avoid clicking my links until they’re ready (aka never) because it will start their limted-time count down clock.
How did your friends handle this? Were they able to combine your webhook method with the Thrive Ultimatum count down timers? I would love to be able to trigger a Thrive Ultimatum campaign using a webhook.
Hi Ben,
It’s been some time since I’ve deep dive into this. I understand your point and I’m surprised by the limitation of Thrive Ultimatum on this point. Are you sure you can’t use a different trigger than a click in an email to start an evergreen campaign there?
The use case of my friend was way simpler and much more closer to a “common” usage (Blackfriday campaign if I remember well and a small scale evergreen campaign after that) so it might not have suffered from such limitations.
Not sure when I’ll get to build a funnel with Thrive Ultimatum next, but I’ll probably play with it in the coming month so I’ll let you know if I can’t find something as good as my hack there.
Let me know how it goes on your side, and sorry for the Thrive U. rec if it doesn’t fit your need.
You can start a Thrive Ultimatum when someone signs up through a Thrive Leads popup box, clicks an email link, or visits a specific URL. There is no way to trigger it through webhooks or at a certain point within the email automation – only when the user interacts wiith your site somehow.
I’m looking into it more now. Please reply comment here if you post any new tutorial about it, and I will also update here if I find something :)
Will do, thanks :)
Man this is awesome. It actually works really well. Thanks alot!
PS: First it didn’t work because i forgot to rename the api libary folder to coupon-gen. Also i had to upload it into the puplic_html folder.
Thanks! Glad it helped :)
Hi,
Old thread, but i will give it a try.
Is it possible to add a prefix or postfix to the email address as coupon?
I’ve found other solutions that create a coupon from a customer email address but the problem is you can’t run multiple coupon codes at the same time that way.
Say you have 5 products. And for all of them you setup a post-purchase automation but you want a coupon with different parameters. 1 is 10% off, another 20%. 1 is 2 days, another 5 etc.
How would you create multiple coupons that way?
Hi Ronald, thanks for stepping by ;)
As you said, it’s an old thread I’m not sure it’s a state of the art solution yet ;)
Scheduling various coupons is possible. You’d have to tweak the script and pass a variable (like $day = 1 or $day = 2, …) in the webhook of the workflow to trigger various coupon configurations.
Also making each coupon expire after 24 hours and possibly deleting the previous coupon through an API call to avoid any conflict on the coupon’s name.
It’s been sometime since I’ve looked at the code though, there might be other (simpler) solutions out there ;)
Hope this helps!
Hi, this is a very interesting solutions!
But i have tried to setup and doesn’t works for me.
I don’t know why.
I’ve turned on the error log but it seems there are no errors.
i have followed all the steps.
Have you some advice for me?
Hey Amos,
Sorry, can’t really help with so little data. Have you tried other, more “turn key” solutions?
hi, thanks for your reply :-)
i’ve tried a lot of solutions “home made” i’m not a developer…
i sent to you one email with the code i’m using, if you have two minutes and want to have a look.
Thank, you are great!
Hi Amos,
Sadly I haven’t reviewed my code in some time now and you might need some basic development skills to tweak it. Just answered your email :)
Have a great day,
I did go ahead and develop this into a full-featured plugin in case anyone is interested, and it supports multiple coupons. By the way, thanks Thomas for the inspiration on this!
That’s great Steve, feel free to post the link here :)
Thanks for your message,
Thanks so much, Thomas! Have a great one :)
Here’s the blog post I wrote: https://dustysun.com/creating-urgency-coupons-woocommerce-activecampaign-automatically/
And the plugin itself: https://dustysun.com/urgency-coupons-for-mailing-lists/