I'm new to the forum, so let me know if I should ask elsewhere. We are a campaigning organisation and much of our campaigning is based on electoral consituency, but I'm not sure how best to capture this info.

How many members we can mobilise in that area, who is the current political representative (MP here in the UK), contacts for the local political parties etc?

I've been playing with the They Work for You API so I can get the constituency based on postcode, but I'm not sure what best to do with it. I'd considered setting the constituency as like an organisation level and the relavent relationships but there are a number of disadvantages to this.

It occurred to me that many other organisations must be in the same boat and wondered if anyone had any experience to share? I'm using latest 4.7 Civi with Latest wordpress. Many thanks,

3 Answers 3


It sounds like you want to look at the Electoral API extension and at Using CiviCRM for e-advocacy more generally.

The Electoral API extension is in beta - we have it in production for a few clients. However, we haven't written support for any APIs except the New York Times and Sunlight Foundation, which are both US-centric sources. Please feel free to extend it to work with UK-based sources!

  • Hey Jon, thanks for your reply. Your extension looks very interesting, is the aim to be able to pull information from a variety of sources? I'd also been looking at the CiviMapit extension @michaelmcandrew developed a few years back. Seems there's been interest from MySociety folk in the past too, so partially trying to get an idea of what is out there.
    – Durruti
    Apr 25, 2016 at 11:57
  • 1
    @durruti Yes, the goal is to populate from a variety of sources. As mentioned, two sources are supported currently - we'd love to see support for more. Also, I submitted a patch for a new hook that will be in Civi 4.7.7 (CRM-18298) that lets you make API calls when geocoding. This paves the way for real-time population of the data rather than via scheduled job. Apr 25, 2016 at 14:54

It might be helpful to set out use cases describing what specifically you want to do with the data: this might tip the balance towards one approach or another.

One approach would be to create a contact subtype for Constituency and then, as you suggest, create a contact for each constituency. As you say, relationships would then be one way to record which constituency someone is in but it makes for a slightly indirect link. You could instead set up a contact reference custom field to record someone's constituency. The field could be restricted to allow only contacts of subtype Constituency.

  • Thanks for your reply Dave. In terms of what I want to do. I created a contact subtype of MP (Member of Parliament), to which I was adding information about voting record, public surgeries, contact details etc. I wanted to display this to users, which I did through an postcode entry, which forwards people to their MP.
    – Durruti
    Apr 25, 2016 at 11:16
  • Essentially I'd like a way to ground users in their political context via constituency - so they can campaign more effectively. Alert them to debates happening within constituency Parties, focus lobbying around particular representives by enabling email to MPs but also promoting when MPs meet constituents, with tokens for these elements for CiviMail and off-line letter campaigns. So 'moon on a stick' essentially, but you did ask. I think the contact reference custom field sounds like a cleaner and more scalable way to do things?
    – Durruti
    Apr 25, 2016 at 11:37
  • There are pros and cons of contact reference fields vs relationships. See e.g. Pulling in existing contact reference fields re Webform CiviCRM. The Electoral API extension sounds interesting; it can be good to build on existing solutions that have been tested in battle by similar organisations.
    – davejenx
    Apr 26, 2016 at 9:57

You might want to have a look at this CiviCRM MaPit integration that I wrote for this purpose: https://civicrm.org/blog/michael-mcandrew/civicrm-mapit-integration.

The demo no longer exists but the extension is simple and I know that it's still in use with an organisation using an up to date version of CiviCRM.

For this implementation, we chose to store the constituency (and other similar) information in a custom field as it made searching, and building custom permissions easier.

Also, https://civicrm.org/providers/Tech-To-The-People do a fair amount of work connecting people to their representatives at an EU level and would likely have experiences to share that would be useful for you.

  • Great thanks Michael, I'll give that a try in the first instance and report back, as we lack the expertise in-house to adapt the Electoral API to a UK setting at this stage. Is it worth adding to the e-advocacy page?
    – Durruti
    Apr 27, 2016 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.