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:    Description: Retrieves MailChimp subscriber count and displays it as a text  Version:     1.0  Author:      WPBeginner  Author URI:     */     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.

Seraphinite AcceleratorOptimized by Seraphinite Accelerator
Turns on site high speed to be attractive for people and search engines.