WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
  • Deals
    • Bluehost Coupon
    • SiteGround Coupon
    • WP Engine Coupon
    • HostGator Coupon
    • Domain.com Coupon
    • Constant Contact
    • View All Deals »
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» Tutorials» How to Show Your MailChimp Subscriber Count in WordPress

How to Show Your MailChimp Subscriber Count in WordPress

Last updated on October 9th, 2015 by Editorial Staff
119 Shares
Share
Tweet
Share
Pin
Special WordPress Hosting offer for WPBeginner Readers
How to Show Your MailChimp Subscriber Count in WordPress

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.

MailChimp Subscriber Chiclet Settings

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.

Getting API Keys for your MailChimp account

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.

Preview of Mailchimp subscriber chiclet plugin

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.

Creating log files

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.

MailChimp API Files

Step 5: Copy and paste Mailchimp.php file and Mailchimp folder to your plugin folder.

Final plugin file structure

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.

119 Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • Revealed: Why Building an Email List is so Important Today (6 Reasons)

    Revealed: Why Building an Email List is so Important Today (6 Reasons)

  • Checklist

    Checklist: 15 Things You MUST DO Before Changing WordPress Themes

  • How to Properly Move Your Blog from WordPress.com to WordPress.org

  • How to Start Your Own Podcast (Step by Step)

    How to Start Your Own Podcast (Step by Step)

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

16 Comments

Leave a Reply
  1. Arnaud says:
    Apr 13, 2019 at 1:32 pm

    Hi,

    The plugin method 2 don’t work.

    Reply
    • WPBeginner Support says:
      Apr 15, 2019 at 12:40 pm

      Thank you for letting us know the methods are not working for you, we’ll certainly take a look.

      Reply
  2. Albert says:
    May 27, 2017 at 6:41 am

    Is it possible to show a member count of a group? What I tried didn’t work.

    Reply
  3. Bernd says:
    May 18, 2017 at 3:25 pm

    Method 1: plugin is outdated.
    Method 2: causes a “fatal error” on activating the plugin

    Any suggestions? Thx.

    Reply
    • Josh says:
      Aug 5, 2017 at 10:52 pm

      Seriously, as above. Keep getting fatal errors. And it seems like nobody is bothering to reply here. Kind of unfortunate.

      Reply
  4. Benny says:
    Jul 17, 2016 at 8:04 pm

    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

    Reply
  5. Mel Reiff Hill says:
    Mar 15, 2016 at 3:07 pm

    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!

    Reply
  6. Dave says:
    Nov 11, 2015 at 2:44 pm

    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

    Reply
    • Roman Rybalchenko says:
      Feb 21, 2016 at 1:30 am

      Same question as above.

      Reply
  7. Fabio says:
    Oct 14, 2015 at 3:46 pm

    Hi,
    is there a way to show the counter only with a php func without a shortcode?

    Reply
  8. Patricia Reszetylo says:
    Oct 11, 2015 at 12:02 pm

    Can you do this for GetResponse ?

    Reply
  9. Chris says:
    Oct 9, 2015 at 3:02 pm

    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:

    Reply
  10. Kim says:
    Oct 9, 2015 at 12:50 pm

    How do people subscribing this way get an email everytime your blog posts a new post?

    Reply
    • WPBeginner Support says:
      Oct 9, 2015 at 9:37 pm

      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.

      Reply
  11. Alex says:
    Oct 9, 2015 at 9:51 am

    Hi,

    cant you do something simialr using the optinmonster sidebar, but without a real time count?

    Thanks.
    Alex

    Reply
    • WPBeginner Support says:
      Oct 11, 2015 at 2:14 am

      yes you can absolutely do this with OM sidebar

      Reply

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
MonsterInsights
MonsterInsights
Google Analytics made easy for WordPress. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 25 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2019 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2019)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2019)
    • SiteGround Reviews from 1032 Users & Our Experts (2019)
    • Bluehost Review from Real Users + Performance Stats (2019)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Create an Email Newsletter the RIGHT WAY (Step by Step)
    • 7 Best CRM Software for Small Businesses (Compared)
    • How to Create a Free Business Email Address in 5 Minutes (Step by Step)
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2019 – Step by Step Guide
Deals & Coupons (view all)
WPEngine
WP Engine Coupon
Get 20% OFF on all WP Engine hosting plans or 4 months free on annual payment.
Visual Composer
Visual Composer Coupon
Get 20% OFF on Visual Composer WordPress page builder plugin.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • RafflePress

Copyright © 2009 - 2019 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

Managed by Awesome Motive | WordPress hosting by HostGator | WordPress CDN by MaxCDN | WordPress Security by Sucuri.