cancel
Showing results for 
Search instead for 
Did you mean: 
In recognition of Martin Luther King Day, our Support Centers will be open with limited hours on Monday (1/20) from 10AM ET to 6PM ET.
Visit our Help Center to see all of the ways you can find answers to your questions.

Keeping only 1 list per contact

Occasional Organizer

Keeping only 1 list per contact

Hi,

 

After ~4 years, we've ended up with 200+ lists, and with many contacts being on multiple lists. This is a problem because we have a hard time ensuring we don't send too many emails to our clients; increases the unsubscribe rate.

 

I am looking to ensure that each contact remains only on the first (or last) list that they are on.

 

I hope that we can entertain some solutions and provide a benefit to others. Appreciate any responses.

3 REPLIES 3
Honored Contributor

Re: Keeping only 1 list per contact

Hello,

 

Based on what you've described, this is technically possible with our API, but I would expect that this has likely not been built out before and would require creation of a new application that would use our APIs to accomplish this task.

 

While this is unfortunately not something that our team would be able to provide, I can definitely provide some advice and guidance to anyone who wishes to build out an application that would perform this task. If you're interested in working on this, I would suggest to take some time to familiarize yourself with our API documentation at http://developer.constantcontact.com/docs/developer-guides/api-documentation-index.html

 

If you have any questions, please let me know!

 

Sincerely,

Elijah G.
API Support Engineer
Occasional Organizer

Re: Keeping only 1 list per contact

I'm surprised this API functionality of mass updating Contact is not in high demand..

 

I have written a rudimentary PHP script (see below) which does walk through the contacts, and updates each contact with only 1 list, the latest one they were found on.

 

Problems:

- I'd need to actually query CC with a parameter for "only on > 1 list" to do this reliably?

- The API has a daily limit of 10K call i believe; assuming 1 contact update = 1 call, i can do < 10K updates per day. For my scenario of ~1M contacts, that means ~100 days.

 

 

$limit = 500; 

$hasNext = true;
for ($page = 1; !$hasnext; $page++) {

$params = array(
'limit' => $limit
);
if ($page > 1) {
$params['next'] = $next;
unset($params['limit']);
}
$all_contacts = $cc->getContacts($accessToken, $params);
if (isset($all_contacts->next) && count($all_contacts->results)) {
$hasNext = true;
$next = $all_contacts->next;
} else {
$hasNext = false;
$next = '';
}

$c = 0;
foreach($all_contacts->results as $contact) {
$c++;
$latest_list = null;
$lists_count = count($contact->lists);
if ($lists_count > 1) {
foreach($contact->lists as $list) {
if ($latest_list === null || $list->id > $latest_list->id) { // pick the freshest
$latest_list = $list;
}
}
// update the contact's list information
$contact->lists = array($latest_list); // rewrite the lists array
try {
$cc->updateContact($accessToken, $contact); // save changes
} catch(Exception $e) {

}
}
if ($c % 100 === 0) {
echo "Parsed another 100..\n";
@flush();
}
}
echo "Parsed ".($limit*$page)." contacts..\n";
@flush();

}
Honored Contributor

Re: Keeping only 1 list per contact

Hello,

 

That code looks like it would definitely be able to accomplish the goal you need. One thing to watch out for with PHP is that by default it has a relatively low maximum execution time, which would likely prematurely end your script.

 

For your two problems, here's some more info:

- Filtering contacts: The V2 API is only able to filter contacts based on three parameters: modified date/time, status(active, optout, etc), and email address. While it is possible that more advanced filtering may be available for future versions of the API, there are not currently plans to expand this for our V2 API. For your implementation, I would strongly suggest filtering by 'active' status, as this saves you the difficulty of parsing removed and opted out contacts that cannot be members of a list.

- API daily limit: This is fully configurable on our side so that we can allow for situations such as yours. If you can email us at webservices@constantcontact.com with a reference to this forum post and your API key, and a rough time frame for when you'd like to run the script, I will be able to temporarily give a substantial boost to your API key in order to allow the process to run.

 

If you have any questions, please let me know!

 

Sincerely,

 

Elijah G.
API Support Engineer