I thought I’d share how to do this since it’s something that ANYONE using WordPress could and probably should be doing if they’ve got any business savvy.
Basically our goal here is to give users an option to join our e-mail list when they register for our website. Sounds simple enough, right?
Neither plugin has been updated since 2009 (which makes them near-ancient at this point, technologically speaking), but I thought I’d give them both a whirl and see what would happen.
AWP wouldn’t even install, so that was an easy cross-off my long list of options. On to ARI!
ARI sort of worked. At times I was able to get it functioning, then other times it seemed to stop working. It also comes packed with this extra feature that monitors which of your registered users elected to opt-in to your e-mail list. It’s sort of pointless to track that natively in WordPress in my not-so-humble opinion, since you can track all of that in AWeber (and most likely any other e-mail software).
Since I’m a such a perfectionist and I don’t like using plugins if I don’t have to, I decided to delve into the code of ARI and figure out exactly how it worked. Here’s the basic gist…
Normally when you want somebody to sign up for your e-mail list, you have them fill out a form which includes name and e-mail input fields. I didn’t realize this until took a closer look at one of those forms, but basically all that happens when somebody clicks “submit” is that a unique URL is generated containing their name, e-mail, and some other parameters.
In essence, clicking submit is like clicking a URL they literally just created on the spot by filling out their name and e-mail. This is how somebody gets added to your list.
I personally use AWeber for all my e-mail lists since it’s easy to manage and it flat-out WORKS. Conveniently, they have a whole webpage explaining all the parameters you need for generating their “add-user-to-list” URLs.
So for example, this URL would add a user with the name Fred and e-mail email@example.com to our hotleads e-mail list:
It’s honestly pretty simple once you break it down. It’s really just an “add lead” URL with some parameters to tell the software who to add to which list.
Getting back to the WordPress registration…
Knowing what we now know about how new leads our added to AWeber, all we need to do is pass along a couple variables (name and e-mail) from our WordPress registration form to generate the add lead URL.
Once we have the proper URL in place, only one problem remains: How do we “click” it?
Meaning that we need some way to have the add lead URL placed in a virtual browser and clicked so that it executes the add lead function. You catch my drift? Just generating the URL does nothing; it needs to be “clicked.”
Luckily I’ve fooled around with web scraping (pulling data from external websites) for PkmnCards, so I knew it would be a pretty simple job with cURL. It basically mimics a user visiting a link (which is exactly what we’ve got to do here).
I looked back through the ARI code again and realized that this is precisely how it works, but for some reason the code is a lot more complex than I could comprehend. I’m not exactly sure why it does some of the things it does.
Anyway, I was able to pull out bits and pieces from the ARI code to help build my own functions. The biggest thing it helped with is making sure I was using the right WordPress hooks.
So without any further adieu, here’s the complete code (which you can plop in your theme’s functions.php):
(Take a look at the full thing then come back here and I’ll break it down for you.)
A couple notes…
1. First, we add First Name and Last Name fields to the default WordPress registration form. You don’t have to do this, but I like to get a user’s full name since it can be pretty powerful to have that in your system.
Think of how nice it would be to customize a sales page on your website if you had the prospect’s full name… I know you could REALLY grab my attention with a headline like…
Or you could do something as simple as say “Welcome back, Adam!” after I log in. Small customizations like that can go a long way. Sure, maybe a couple less people will register for your site because they don’t want to take 5 extra seconds to type out that info (or maybe they don’t want to share it), but I think the leverage you gain is well worth a few less leads.
2. The code after the extra fields checks to make sure the user actually entered their first and last name, and then it saves that info to their profile.
If you were saving a custom data field to the user’s profile, you could need to save it like this:
update_usermeta( $user_id, 'CUSTOM_DATA', $_POST['CUSTOM_DATA'] );
A little more on that in a minute…
3. Finally we get to the good stuff… first we insert an opt-in checkbox so the user can decide whether or not they want to subscribe to our e-mail list. I have it checked by default via
checked="checked", but you don’t have to do that if you don’t want. I think it’s smart to do that though.
If you want to be really on top of your stuff, you could try and get even more info from the user and add them to a segmented list. For example, you could have them select their country, and create conditional statement for the next part of code to add them to a specific list.
Or ask for their gender… favorite food… stuff like that. Any info you can gather to send them specified e-mails is valuable. Think of how much information Facebook and Google try to gather and then market back to you. This information can then be saved to the user’s profile via
update_usermeta( $user_id, 'CUSTOM_DATA', $_POST['CUSTOM_DATA'] ); which I mentioned earlier.
4. Lastly, we check to make sure the user opted-in to our list, then we build the “add lead” URL and “click” it with CURL. I will admit it’s not the perfect cURL code as I was running multi-cURL for another project and didn’t feel like changing it back to singular cURL. This shouldn’t have any effect on performance, but feel free to edit if you want.
IMPORTANT: Make sure to change
$adtracking to suit your needs.
Again, you could customize this by adding conditionals and multiple lists depending on what kind of information you ask the user during registration.
What I would do if you’re using AWeber is to create a main list, which we’ll call mainlist, and then sublists, which we’ll call sublist1 and sublist2. You will want to add users to either sublist1 or sublist2 depending on whatever conditionals you make, but then I’d also add them to mainlist via AWeber automation tools.
This way you have a “master list” with all your leads, but also the targeted lists. You could alternatively just have 1 list and then create segments via AWeber custom fields, but I find it simpler to have separate lists. You gain a little more flexibility with lists and can do some cool things with them.
You could also probably adapt this to get leads if someone comments on your site. I don’t know the proper hooks, but I’m sure it’s pretty simple to add a “Join my list!” checkbox to your commenting form (just like we do for the WordPress registration form here).
Anyway, I ain’t no perfect coder, so let me know if you see any mistakes or have any suggestions. This is pretty powerful stuff and I’m surprised it isn’t more well-known or used.
Catch you on the flip,