Get number of active subscribers?

Hi!

I'm new both to Campaign Monitor as well as the API, but I've integrated the full subscribe/unsubscribe process into my site using the API (not using auto-generated forms or anything).

But what I now would like, is to get the *number* of active subscribes to a certain list, dynamically via the API. Is there any way to do this?

Script language is PHP by the way.

Thanks a lot for any advice!

Regards,

Jonathan

Blake, 7 years ago

Hi Jonathan,

Yes, you can do this using the Subscribers.GetActive method and using the count() function to count the number of active subscribers returned.

Hope that helps.

virtuality, 7 years ago

Hi Blake!

Thanks for your reply. I guess my PHP knowledge is limited after all.

So I'm calling GetActive and that returns an array with all the emailes etc.

If I use the standard coun()-function on it, I get the number 1 as a result. If I run count() in COUNT_RECURSIVE mode instead, I get 10225 as the subscriber count, which is way too many. I guess it counts each field (email, date, state). But then it should be enough to just divide that by 3? No, that doesn't work either. Still the wrong number.

What am I missing? Am I being really stupid here? :) I looked around for ways to extract only certain info from the array, but that didn't go too well.

Thanks a lot for your help here.

djwhisky, 7 years ago

It would be great to get this in the List.GetDetail API call... it seems overkill to me to pull down details of every subscriber just to get a total count - on a large list this could be quite a lot of data to pull down over the wire?

Joomailer Joomailer, 7 years ago

@virtuality:

$subscribers = $cm->subscribersGetActive( 0 , $listid );
$count = count( $subscribers['anyType']['Subscriber'] );

That should do the trick.

Make sure the $subscribers array has the same structure with one and several entries before counting according to this thread: http://www.campaignmonitor.com/forums/viewtopic.php?id=2765

@djwhisky:

I totally agree. If there is a votecount on this, add one for me ;)

Cheers


-----------------------------------------------------------------------------------
Joomailer.com - Campaign Monitor Integration for Joomla!
-----------------------------------------------------------------------------------
jamesd jamesd, 7 years ago

A new List.GetStats API method will be available in our next release, which will return an object containing the following data for a list:

- TotalActiveSubscribers
- NewActiveSubscribersToday
- NewActiveSubscribersYesterday
- NewActiveSubscribersThisWeek
- NewActiveSubscribersThisMonth
- NewActiveSubscribersThisYear

We decided to separate the statistics of a list from the "details" of a list by adding this new method rather than combining everything into the existing List.GetDetail method.

Since it's currently in development, are there any other list stats which people would find valuable?

Joomailer Joomailer, 7 years ago

It would be usefull to get also the amount of unsubscribes and bounces within this API call.

Another thing I can think of is to include the stats of last week, month, year to be able to compare them without having to save these data regularly into a database.

Regards,
Pete


-----------------------------------------------------------------------------------
Joomailer.com - Campaign Monitor Integration for Joomla!
-----------------------------------------------------------------------------------
jamesd jamesd, 7 years ago

List.GetStats has recently been updated to include stats for active subscribers, unsubscribes, deleted and bounced subscribers, which allows you to easily get a current snapshot of stats for your list.

Joomailer Joomailer, 7 years ago

That's awesome! Will save us a quite a few lines of code in the future. Thanks for including our suggestions aswell!

Cheers


-----------------------------------------------------------------------------------
Joomailer.com - Campaign Monitor Integration for Joomla!
-----------------------------------------------------------------------------------
Joomailer Joomailer, 6 years ago

Hello,

Unfortunately I noticed that in some cases the call List.GetStats seems to deliver incorrect values. I have a list for example with 2 active subscribers but the call returns TotalActiveSubscribers = 1.
I was wondering if there was some error in our code that caused these wrong numbers but it seems to be already the API which delivers incorrect values. Could you please take a look and see if you can fix it?

Thanks.
Kind regards,
Pete - joomailer


-----------------------------------------------------------------------------------
Joomailer.com - Campaign Monitor Integration for Joomla!
-----------------------------------------------------------------------------------
jamesd jamesd, 6 years ago

Hey Pete,

Could you contact support with the details of the client and list for which you're seeing this problem, as well as the the API key you're using? That will help us track down what the problem could be.

Joomailer Joomailer, 6 years ago

Cheers, done.


-----------------------------------------------------------------------------------
Joomailer.com - Campaign Monitor Integration for Joomla!
-----------------------------------------------------------------------------------

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098