Retrieved Contact Count > Infusionsoft Site Count

Hello,

I wrote a query to see how many contacts we have in our system and compared it to what our main site says to see if it was accurate but there are some inconsistencies. Here is the query for all contacts:

$dated = (string) date(“Y-m-d”);
$query = array(“LastUpdated” => “~<~ “.$dated.” 00:00:00”);
$contact = $infusionsoft->data()->count($table, $query);
echo json_encode($contact);

This returns about 16,000 when our site says we have about 13,000. I was wondering if some of these aren’t contacts or if the query wasn’t written properly. Additionally, I wrote a query to try to get how many contacts were lastupdated in a month and it is also returning a large amount of records. Here is the query:

$query = array(
“LastUpdated” => “~<~ “.$date->format(‘Y-m-d’).” 00:00:00”,
“LastUpdated” => “~>~ “.$end->format(‘Y-m-d’).” 00:00:00”,
);

Where $date->format looks like (“2018-03-31”) and $end->format looks like (“2018-03-01”). Infusionsoft has something like this:

quick

Which is what I am looking to do.

Any help would be appreciated, thank you!

Hi @Rameal_Nabeeh, it appears that company records are mistakenly being included in the count of contact records. I would suggest submitting a support ticket detailing this issue so we can get a bug ticket created.

As a work around, you could take the count of companies and subtract it from the count of contacts. That should give you an accurate number.

Yup, as @Nicholas_Trecina, has suggested, that is exactly what happens with the dsCount method on the contact table and his work around is the only one I know of. It’s actually been the case for a while. Hopefully as updates to REST come, that will clear up with it.

Okay, I’ll try the work around I just thought I was doing something way wrong. Thanks guys, I appreciate it.

Nope you are doing perfect :wink: Took me over five hours years ago when I was learning the IS API to find this out… hopefully your ‘journey’ was quicker :stuck_out_tongue_winking_eye:

Frustrating but quicker definitely quicker :slight_smile: but I still have questions on it because I really want accurate results. So when I write a query like this:

$table = “Contact”;
$query = array(
“LastUpdated” => “~<~ “.$date->format(‘Y-m-d’).” 00:00:00”,
“LastUpdated” => “~>~ “.$end->format(‘Y-m-d’).” 00:00:00”,
);
$contact = $infusionsoft->data()->count($table, $query);
echo ($date->format(‘Y-m-d’)." records: ".json_encode($contact));

And I input the values for $date as March 31st 2018 and for $end as March 1st 2018 I get 1616 records when there are actually 91 in our database. I tried also writing this same code but with the table as Company and it only returned 73 records. I was going to do a subtraction on these 2 values to hopefully hit 91 but obviously that still isn’t the right amount of records. Am I not doing this right or is it better if I just write a query that returns all the records and then do an array.length operation and get the count that way. I’m interested in speed which is why I used the count function (because I thought it’d be faster) but accuracy trumps speed for my use case. Thanks for the help!!!

Actually it would be helpful to know how infusionsoft can tell that we have 13k contacts. I tried filtering contacts without a name or without an email or something like that but I’m not getting the same number as infusionsoft. For example maybe infusionsoft queries the contacts table and checks whether some values aren’t present or something to get to the count that it does. Thanks

Actually, what I would do is to get 1000 records at a time (the most you can call for in one call) and then check to see if the AccountId field is the same as the Id field. Those that are, are companies. Increment a counter for them and you should get more accurate results.

That worked you guys are the best!

1 Like