Online social media is growing in complexity
The role of online social media continues to grow in importance for political organizations. Facebook, MySpace, YouTube, Flickr, Twitter, and dozens of other sites need to be managed, tracked, and integrated. This takes a lot of staff time, but luckily these services continue to expand their support for external programs that can manipulate data or perform actions. APIs (application programming interfaces) allow different websites or computers to talk together and do things in the background. Even sites which don't provide official APIs can often be automated using third-party tools.
Loading emails into Gmail contacts fosters integration
In this article I'll show one simple script that uses Python and a third-party library (libgmail) to load a file of emails into gmail contacts. It's very common for web applications to support interfacing with gmail accounts to add users, so once your emails are in gmail it's simple to import them into Flickr, Twitter, etc.
The benefits of data integration
Why do this? Well for one, it helps organizations bootstrap their social media relationships. Normally your email list will be the largest medium for contacting members, so syncing that list into other services can really jump start your campaigns there. Rather than start from scratch you can build off your existing members, connect with them in different ways, and expand your online communication offerings. Even better, integrate social network synchronization into your data workflow: e.g. on a nightly (or hourly) basis sync new email subscribers into gmail, then sign into your socnets and add any new accounts you find. The "add any new accounts" step can be automated as well and will be explored in a later article.
Running the code
Python is the scripting glue for gmail_add_contacts.py, and I use libgmail to interface with Gmail. Libgmail requires the mechanize module if you haven't already installed it, but if you have easy_install it's a single command. Here are the commands (I'm on OS X):
It will take a while to load the emails into gmail, but once they are there it's just a few clicks to add all your members on Flickr, Twitter, or any other service that can import from gmail contacts!
Following our volunteers on Twitter
I tested this concept by loading 5,215 volunteer records into gmail. Of those, 590 could be found on Twitter (11.3% match rate) - not too shabby. And because the contacts are stored in gmail, I can always import again, say once a month, and add members who have recently joined. It would be interesting to see people try this for their own members and see what the match rates are for different services and organizations.
- Create a new gmail account specifically for this data sync - don't use an existing account.
- Every 2,000 records or so gmail will stop processing records and the script will abort. Just run it again and it will resume where it left off.
- Twitter seems to only add up to 200 followers at a time, but you can repeat as needed.
- Because it is slow, this method works best as part as incremental workflow on new records. For loading existing email records it may be easier to use gmail's import contacts via csv feature. The problem with the csv method is that it's limited to 3,000 contacts per file, so in order to handle more than a few thousand records you'll want an automated solution.
- In theory, once you import email records into a service, you will want to capture the respective username & id for that email record. Then you can integrate that into your main database and use it for future messaging (potentially via that service's API). This would be automated.
- Feel free to fork and make improvements to gmail_add_emails.py. It's easy to do on github. Or post feedback here.
- Tip of the hat to KF for thinking of an email -> Twitter data sync in the first place. Good call!