I am just starting to play around with the new API and I am having a few problems trying to accomplish something here. This is what I have to do:
I already have my contacts in a list, with a few custom fields, and now I must add 1 new custom field to the existing contacts, and populate that field with a different code for each recipient.
I would have to first add the custom field directly on the system.
I believe I know how to do this if I was adding a new contact, but how do I loop though all my existing contacts and add new data for a custom field?
Thanks in advance.
The simplest (but not necessarily the quickest) way of doing this would be to:
1. Get the list of active subscribers you need to update using: http://www.campaignmonitor.com/api/lists/#getting_active_subscribers
2. Iterate through all the subscribers and update their details using: http://www.campaignmonitor.com/api/subscribers/#adding_a_subscriber (ensuring that you include the new custom field in the CustomFields input)
The other approach you could take would be to export the list of subscribers and then use http://www.campaignmonitor.com/api/subscribers/#importing_subscribers to bulk re-import them, including the new custom field in the input.
Hey Bruno, I had the same problem a few weeks ago and from my experience importing a .csv file manually is the fastest solution (a matter of seconds).
The problem with updating through the API (the older version) is that my PHP script got a time-out for every 2,000 updates (I was updating around 10,000 subscribers).
If I just export my current contacts to a CSV file, and add the new column with the unique code to it, when I reupload that file back into CampaignMonitor, will it just upload my current contacts (i.e. just add that new field to each) or will it overwrite all my contacts?
Since I already sent a few campaigns to this list I would like to keep the historical data for each contact.
Any existing contacts which you re-import will be updated. See the import help topic: http://help.campaignmonitor.com/topic.aspx?t=12
Great! I just noticed that.
Perfect. For this one time I believe the suggestion of bc173 will be faster.
From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that drive real business results.Get started for free