Tip: Capturing subscribers from an existing form
We’ve made it very simple to create a form on your web site where new subscribers can sign up to your list (we provide the code, you just have to copy and paste). But what about when you’ve already got a form, and you simply want to add a checkbox where customers can opt-in to your newsletter? This isn’t quite a copy and paste job, but it’s not far off.
Lets take a look at a simple example. Your client’s site has a ‘Contact Us’ form, which sends an email to your client with the details of a customer enquiry. They’ve just decided that they want to add a little ‘Subscribe to our newsletter’ checkbox. How are you going to integrate this with Campaign Monitor? Here’s a few ways:
1. Use an extension or plugin
This is the simplest of all if you happen to be using a suitable CMS or shopping cart. We’ve got a bunch of downloadable plugins, extensions and modules for systems like Expression Engine, Joomla and FoxyCart.
Over on the right of this page you’ll see direct links to some of them. Check there first because it may be someone has already done the hard work for you.
2. Using the API
Lots of you already know about (and use) the API, and this is the obvious way you can achieve this. In our example, when a user submits the contact form on your clients web site, your already going to have some code in place to gather the contents of the form, and send them off to your client in an email (usually in something like PHP, ASP.NET, Perl etc). We just need to make a slight addition to this.
Using your programming language of choice you can check to see if the user has checked the ‘Subscribe to our newsletter’ checkbox, and if they have, make a call to our API to save this person to your subscriber list. And don’t worry if they’re already in there - we won’t add them twice.
3. Redirecting to specific URL’s
If your not too keen on the idea of calling our API, there’s another method you can use, which works by redirecting to a URL on our server which will save the user to the list, then send them back to your server.
So just like before, you gather the contents of your form, and send the email to your client. Now, to get the users name and email address into Campaign Monitor, we need to redirect the user to a specific URL.
What this redirect stuff you keep mentioning? All server side languages should have an easy way to send the user to another URL. In PHP you would use something like:
header( “Location: hh>ttp://www.urlhere.com” );
and in ASP.NET it would look likeResponse.Redirect(“http://www.urlhere.com”).
So let’s get down to specifics. The URL that we need to send the user to, is the same URL that we use in the Create a Subscribe Form code. Check out this code and you’ll see something like:
<form action=“http://myclient.thisapp.com/p/a/t/tos/” method=“post”>.
The action URL is what we’re after, so in this case
http://myclient.thisapp.com/p/a/t/tos/.
We’re almost done, but when we redirect the user to the URL we need to include their email address (and optional name). We do this by adding them to the URL in a format like this:?cm-4841-4841=sample@test.com&cm-name=Joe+Bloggs.
So the full code in PHP would beheader( “Location: http://myclient.thisapp.com/p/a/t/tos/.
?cm-4841-4841=sample@test.com&cm-name=Joe+Bloggs” );
The important points to note are the question mark (?) to show the start of the variables, the ampersand (&) to separate the values we’re passing in, and the plus sign (+) which should be used to replace any spaces in the name.
Of course, you’ll need to grab the name and address values from your existing form, and plug those in where we have sample@test.com for example.
When the user is redirected to the above URL, they will be added to your list, but what happens next? Well, hopefully you’ve added a custom subscribe page (and if you haven’t, just jump into the “Create a Subscribe Form” options in your list and add one), and the user will be redirected back to the subscribe confirmation page you’ve specified.
The best part is, both of these approaches happen so quickly the user won’t notice a thing.
Posted in: Tips & Resources
Comments for this entry are closed.
Browse the Blog
- Behind the Scenes (28)
- Interviews & Buzz (132)
- New Features & Updates (229)
- Observations & Answers (210)
- Release Notes (1)
- Tips & Resources (478)
Explore the Email Gallery
- All designs
- One column (368)
- Two column (221)
- Three column (33)
- Announcement (126)
- Newsletter (445)
- Invitation (37)
@herron_bird That’s totally awesome - thank you for checking out worldview! :D ^RH
Follow us on TwitterAbout • Our Book • Contact • API • Anti-spam Policy • Terms of Use • Privacy Policy
Proud founders of the Email Standards Project and supporters of the design community.
20 Comments
Brian
March 11, 2006 9:11am
Using the second method (via GET) would the person be directed to the unsubscribe page (as you indicated) or to the subscribe / Initial Confirmation page on the account? It seems to make more sense to direct the user to the Initial Confirmation Page.
Dave Greiner
March 11, 2006 11:00am
That’s right Brian, as soon as we’ve added them to your list, we’ll redirect them straight to your confirmation page (which happens in milliseconds). If it’s a double opt-in list, we’ll send them to the initial confirmation page, plus send them a confirmation email with a link to click to confirm their subscription.
Using these methods is just like the subscriber completing the standard subscribe forms we supply.
Dave Greiner
March 14, 2006 10:47am
Brian, my apologies, we accidentally said the unsubscribe page, when we meant the subscribe confirmation page. Thanks for pointing that out, the tip has been updated.
Gil
March 23, 2006 1:51pm
Sorry, but this is little hard to non-PHP-programers. But is a very important issue. We really need to add a ‘Subscribe to our newsletter’ checkbox in every form we have. But, please, explain again the “after We’re almost done” part. And, again, sorry. And thanks!
rick kirk
March 24, 2006 6:43pm
Good Post Gil!
This is something that would be VERY helpfull Dave.
Please provide some cut-n-paste checkbox code, (or step by step guide) for us to add to our existing forms to sign people up to the list, like the heading on this page implies!
thanks a lot.
David Greiner
March 24, 2006 8:24pm
Hey guys, sorry if this wasn’t as clear as it should have been. I’d say that the best approach for Gil and Rick would be the second approach. Here’s a quick step by step:
1. Get the address you should be redirecting to
This is the action= address from your subscribe form for that list.
2. Modify your existing subscribe form code
Normally when you process a form, you’ll redirect the user to a confirmation or thank-you page. Add a check to make sure someone has checked your list opt-in checkbox. If they have, we want to redirect them to the address specified above instead of the usual thank-you page. Before we do that, there’s one last thing…
3. Add the new subscriber’s email address and name (optional) to the address of the page we’re redirecting to.
We do that by adding a question mark (?) and then email= their email address &name;= their name.
The full address should look something like:
http://myclient.ourdomain.com/.asp/s/4841/
?email=benr@campaignmonitor.com&name=Ben+Richardson”
4. Set a subscribe confirmation page
We can now redirect them back to the same old thank-you page that we always use, so just copy and paste that address into the “Subscribe Confirmation Page” for that list in “Create a Subscribe Form”.
Unfortunately there just isn’t any “copy and paste” approach here, because this depends on your server side language and each is different.
Please let me know if any of this is unclear.
Luiis
September 13, 2006 7:14pm
Hi,
I have created a newsletter form with custom fields, but when I try to subscribe me I receive this error:
“Invalid Email Address”
I use ASP.NET 2.0, and the second method, the URL string is:
http://myclient.yourdomain.com/.asp/s/4841/?l74295-74295=mail@mail.com&firstnamemyfirstname&lastname;=mylastname
I have tried also:
http://myclient.yourdomain.com/.asp/s/4841/?email=mail@mail.com&firstnamemyfirstname&lastname;=mylastname
BUt doesn’t work :(
Dave Greiner
September 13, 2006 9:23pm
H Luiis, if you’re still having problems, your best bet is to submit a support incident and we’ll look into it for you.
Barry
October 14, 2006 6:29am
Trying to successfully pass a hidden parameter from an email to a web-based page with a form, and DB query (already there and handled by Oracle).
Is there a way to do this from MS Outlook? I keep getting a file name NULL but if I copy and paste the code in a raw HTML form/page, it works fine.
Matt Williamson
October 19, 2006 11:43am
I’d like to swap out my DIV instead of redirecting to a new page. Is there a tutorial or article somewhere so I can figure this out? I submitted a support request to mailbuild already and have not heard anything yet.
Thanks!
Dave Greiner
October 19, 2006 5:19pm
Hey Matt, thanks for the chat earlier. Well try and get that new article together for you and everyone else soon.
Liam
October 25, 2006 11:52pm
Hi,
I’m sorry in advance for not being too up on php scripts.
I have an online form when submitted gives a message that states your submission was succesful(or whatever message you wish to convey) The online form details are e-mailed to the allocated e-mail address.
All fine and good except for the “successful submission” message is on a white background with black text which clashes with the websites colours.
My question is can I add a redirect code to my existing script so as I can redirect to my website page (with colours etc. as I wish) while allowing for the form to work as is?
and where do I add this exact code in my existing script.
Thanks & Regards,
Liam
A Maclean
December 1, 2006 1:18am
Hi, my client has a classic asp site. They wish to use Campaign Monitor, Does any one have an example for classic asp. I had no issues getting the web service running with asp.net 2.0.. just after a simple option for classic now.
Many thanks in advance
A
Ben Richardson
December 1, 2006 1:39pm
Hey A,
Getting this working with classic ASP shouldn’t be a problem. There are a couple of techniques you could use, such as the redirect method discussed above, or via the API using SOAP - here’s an example of using SOAP with classic ASP.
If your still having problems please contact support and we’ll be able to help you out.
Mark Hirst
January 31, 2007 7:11pm
I need to do this too and am trying to decide which method to use. You seem to sugest that the API is the better solution but I cant figure out where I am to start using this method. Are there any instructions anywhere on how to achieve the above using API? API is completly new to me, does this mean I should consider the second method?
bilgisayar
July 26, 2007 10:55pm
Are there any instructions anywhere on how to achieve the above using API? API is completly new to me, does this mean I should consider the second method?
Ketan Vakil
July 27, 2007 9:46am
Does anyone have an example of either the API or the redirect method working on an ASP server? Even with the redirect method, you still need to use some sort of ASP variable to hold all the data to use in the redirect string, correct?
Thanks!
Dave Greiner
July 27, 2007 10:38pm
Ketan, to give you the best chance of getting an answer, I’d recommend posing that in the API section of our forums.
Roksana
September 14, 2008 5:27am
They wish to use Campaign Monitor, Does any one have an example for classic asp. I had no issues getting the web service running with asp.net 2.0…
bet365
September 14, 2008 5:29am
I have an online form when submitted gives a message that states your submission was succesful(or whatever message you wish to convey) The online form details are e-mailed to the allocated e-mail address.