Start turning email addresses in to useful information – part 1

TL/DR – Take an email address such as joebloggs23423@hotmail.com, and turn it in to useful information such as: Firstname: Joe, Surname: Bloggs, Gender: Male.

If you have developed a web application which allows users to sign up using a username or an email address or if you maintain a newsletter subscriber list or if you are capturing email addresses from users on landing pages, you may want to expand on your existing information to determine a users full name, gender, location and age so that you can better trailer your web application or newsletter to your particular audience, or just have more complete information in your CRM system. This is a brief guide to show you how to get started and turn a username or email address in to a name and gender.

There are a number of API’s to help with this and here are a couple of useful ones which are Free to use:

Determine a persons full name from a username or email address:

This is using an API from FullContact called Name Deducer. To use the API, sign up for a free API key and then send a query to their system like the following snippet (change the parts in Red to the email address/username that you want to look up and the API to your own API key provided by FullContact.)

<?php
$url = 'https://api.fullcontact.com/v2/name/deducer.json?email=joebloggs23423@hotmail.com&apiKey=XXXXXXXXXXXXXXXXXX';
$response_json = file_get_contents($url);
?>

You will receive a JSON response

{
  "status": 200,
  "likelihood": 0.68,
  "requestId": "5d80a469-60bc-4452-b999-81e353a4f18e",
  "nameDetails": {
    "givenName": "Joe",
    "fullName": "Joe Bloggs"
}

From the above output, you can pull out the ‘fullName’ and update your database. You could also look at the ‘likelihood’ value to determine how confident the FullContact API response is of this users name.

Determine a users Gender from their First name

Once you have a users name, the next step it to use another API from http://genderize.io/ to determine Gender.

<?php
$url = 'http://api.genderize.io?name=Joe';
$response = file_get_contents($url);
?>

Again, you will receive a JSON response:

{"name":"Joe","gender":"male","probability":"0.98","count":1604}

From this output you can see that Joe is determined to be Male with a probability of 0.98 out of 1. The API is free, but limited at 2500 requests/day which isn’t bad. You could get a little bit more mileage by comparing a name with your existing names before you send it to Genderize.io more than once.

What if I have users in different countries?

Its also possible to determine the Gender of a name and additional details using FullContact’s other ‘Name Stats’ API call. However I included Genderize here because FullContact is US-specific which might not be ideal here in Europe. Genderize allows you to specify a Country Location code so it will in theory return the more appropriate Gender for that country. If you don’t have the Country of the user, then hopefully you are capturing the users IP Address and determine the Country from that using http://dev.maxmind.com/.

As a result of the above, you now have an email address, full name and Gender.

In a future post, I will talk about how to expand this information further.

One Comment

  1. Pingback: Extract useful information from notification emails | Murrion Software

Leave a Reply

Your email address will not be published. Required fields are marked *