Do you want to display your MailChimp subscriber count? Recently one of our users asked us how they can show their MailChimp subscriber count in WordPress. Displaying social proof encourages other users to join your newsletter. In this article, we will show you how to show your MailChimp subscriber count in WordPress.
MailChimp is one of the most beginner friendly email marketing service provider. If you are not already using MailChimp, then check out our guide on using MailChimp with WordPress.
We will be showing two different methods to display MailChimp subscribers count. The first method is easier and requires you to install a WordPress plugin. The second method is more advanced where you will need to create a plugin based on different source files. If you are not comfortable with editing code snippets, then we will recommend you to use the first method instead.
Method 1: Using MailChimp Subscriber Chiclet Plugin
First thing you need to do is install and activate the MailChimp Subscriber Chiclet plugin. Upon activation, visit Settings » MailChimp Subscriber Chiclet to configure the plugin.
First you will need to enter your MailChimp API key. If you haven’t created one, then you can login to your MailChimp account dashboard and get one.
After entering your API key click on the Save Changes button. The plugin will then load your email list from your MailChimp account. Select your email list and configure the plugin settings.
Once you are done, simply copy the shortcode from the bottom of the plugin and add it to any post, page, or text widget where you want to show your subscriber count.
Method 2: Getting Subscriber Count Using MailChimp API
As you would notice that using the plugin method you get your subscriber count with a powered by MailChimp logo. Many users would just want to get the number so that they can use it with their own email signup forms.
In this method we will be creating a plugin. This plugin will use MailChimp’s API to get subscriber count. You will be able to display the subscriber count anywhere you want using a shortcode.
Step 1: First thing you need to do is to create a folder on your desktop and name it mc-subscriber-count.
Step 2 Inside the folder create a new file and name it mc-subscriber-count.php and paste this code inside it.
Important: Don’t forget to replace Your_MailChimp_API_Key with your actual MailChimp API Key.
<?php /* Plugin Name: MailChimp Subscriber Count Plugin URI: https://www.wpbeginner.com Description: Retrieves MailChimp subscriber count and displays it as a text Version: 1.0 Author: WPBeginner Author URI: https://www.wpbeginner.com */ function wpb_mc_sub_count() { include "Mailchimp.php"; $lastRunLog = 'logs/lastrun.log'; $subfile = 'logs/subcount.log'; $lastRun = file_get_contents($lastRunLog); if (time() - $lastRun >= 86400) { $MailChimp = new MailChimp('Your_MailChimp_API_Key'); $mc = $MailChimp->call('lists/list'); $subscriber_count .= $mc[data][0][stats][member_count]; file_put_contents($lastRunLog, time()); file_put_contents($subfile, $subscriber_count); } else { $subscriber_count .= file_get_contents($subfile); } return number_format($subscriber_count); } add_shortcode('mc-subscribers', 'wpb_mc_sub_count'); add_filter('widget_text', 'do_shortcode'); ?>
Step 3: Inside mc-subscriber-count folder create another folder and name it logs. Inside the logs folder create two blank files using a plain text editor like Notepad. Name one file lastrun.log and the other subcount.log.
Step 4: Download the MailChimp PHP Wrapper source code from MailChimp repository. Download link is located at the bottom in the right hand column.
After downloading, you need to extract the zip file. Inside the extracted folder, you will see a folder src containing Mailchimp.php file and Mailchimp folder.
Step 5: Copy and paste Mailchimp.php file and Mailchimp folder to your plugin folder.
Step 6: Upload mc-subscriber-count folder to /wp-content/plugins/ folder on your website using an FTP client.
Step 7: Visit the Plugins page on your WordPress admin area and activate MailChimp Subscriber Count plugin.
Step 8: Use shortcode [mc-subscribers]
to display MailChimp subscriber count in any post, page, or text widget in WordPress.
We hope this article helped you show MailChimp subscriber count as text on your WordPress site.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Jiří Vaněk
Thank you for the guide. I use the free plan of Mailchimp and have it integrated with my website through Optin Monster. Following your instructions, I will try to incorporate the display of subscribers in the information about joining the newsletter. This could definitely influence people’s decisions when they see that the email list is already relatively large and that other users have placed their trust in my website and its information. It’s another small step towards making the subscription more appealing to my users.
Arnaud
Hi,
The plugin method 2 don’t work.
WPBeginner Support
Thank you for letting us know the methods are not working for you, we’ll certainly take a look.
Admin
Albert
Is it possible to show a member count of a group? What I tried didn’t work.
Bernd
Method 1: plugin is outdated.
Method 2: causes a “fatal error” on activating the plugin
Any suggestions? Thx.
Josh
Seriously, as above. Keep getting fatal errors. And it seems like nobody is bothering to reply here. Kind of unfortunate.
Benny
This does NOT work.
Don’t even bother following his methods.
Method #1 is outdated and not supported.
Method #2 you will be surrounded by
“Fatal error: Cannot redeclare class whatever on line whatever
Mel Reiff Hill
Thanks for the code, but the diy plugin seem to no longer work (I show 0 subscribers after following instrux…) Just thought it might be worth an update!
Dave
Thanks for the awesome tutorial. Can you kindly explain how to specify which list to count, in the case of having multiple mailchimp lists?
At the bottom of lists.php, I tried adding my list_id into the $filters array, as such:
public function getList($filters=array(‘list_id’ => ‘abc123’),…
(with abc123 corresponding to my actual list_id)
But this didn’t seem to work. Or should I expect a long delay time before it starts working?
Thanks,
Dave
Roman Rybalchenko
Same question as above.
Fabio
Hi,
is there a way to show the counter only with a php func without a shortcode?
Patricia Reszetylo
Can you do this for GetResponse ?
Chris
The plugin is horrible: using an image as background!
For those who like to use it AND get rid of the logo and the bad typo and bad styling, here is the CSS to get rid of it; put it in the custom.css of your theme:
.mailchimp-subscriber-chiclet-for-wordpress .mailchimp-subscriber-chiclet-for-wordpress-wrapper .mainButton {
background-color: #B09AAB;
background-image: none !important;
color: #FFFFFF;
font-family: inherit;
font-size: 14px;
height: 30px;
text-align: center;
width: auto;
padding-top: 3px;
}
With this it looks nice with my theme:
Kim
How do people subscribing this way get an email everytime your blog posts a new post?
WPBeginner Support
Please see our MailChimp guide for WordPress users. You can also learn more in our tutorial on how to create a daily or weekly email newsletter.
Admin
Alex
Hi,
cant you do something simialr using the optinmonster sidebar, but without a real time count?
Thanks.
Alex
WPBeginner Support
yes you can absolutely do this with OM sidebar
Admin