Filtering by Demographics

One of the most powerful features of PYLON is the access you're given to demographic details of users. We'll take a look at some of the options you have in this document, specifically working with Facebook topic data. Unlike some sources you may have worked with in the past the Facebook graph contains demographic details for the vast majority of users.

You can use any of the examples below when creating an Interaction Filter in the dashboard or when compiling a filter using the API & client libraries.

Stories versus engagements

You might have already read our introduction to Facebook topic data - which explains the data available to you.

When you work with demographic data the targets you use sit in the fb.author.* and fb.parent.author.* namespaces.

  • Stories - have authors who's details can be found in the fb.author.* targets
  • Engagements - have the details of who engaged in the fb.author.* targets, but also the details of the original story's author in the fb.parent.author.* targets

It's worth taking a moment to consider what types of interactions you want to filter to. Here are some example scenarios.

All interactions from a demographic

To filter to both stories and engagements created by a certain demographic use both the fb.author.* targets. This example will capture stories created by people from 35 to 44 and engagements by the same age group on stories posted by anyone of any age group.

fb.author.age == "35-44"

note icon

You may have expected the following CSDL for the example above:

fb.author.age == "35-44" OR fb.parent.author.age == "35-44"

However this would be incorrect. As both stories and engagements have the fb.author.* targets the first condition will capture all stories and engagements from the demographic. The second condition using the fb.parent.author.age target will additionally capture engagements by any user on stories created by 35-44 year olds, so engagements by users outside our target demographic.

Stories only from a demographic

To filter to just stories created by a demographic use targets from fb.author.* and specify stories only using the fb.type target.

fb.type == "story" AND fb.author.age == "35-44"

Engagements only by a demographic

To filter to just engagements created by a demographic use targets from fb.author.* and specify the engagement types you require using the fb.type target.

fb.type IN "like,comment,reshare" AND fb.author.age == "35-44"

Engagements on stories created by a demographic

To filter to all engagements on stories created by a demographic just use targets from fb.parent.author.* as only engagements have these targets. In this example using the parent target restricts the data to engagements only and the target itself specifies the age of the author who created the story being engaged on.

fb.parent.author.age == "35-44"

note icon


The following examples assume you're filtering for all interactions, but you can use the templates above to adjust your filters as you see fit.

Filtering by age & gender

Age groups

Let's start by looking at age. Authors are grouped in to age bands, these are detailed on the targets pages fb.author.age and fb.parent.author.age.

Note that accounts of users under 18 are not available for recording.

To filter to interactions from one specific age group:

fb.author.age == "35-44"

Or, to filter to interactions from multiple age groups:

fb.author.age in "18-24, 25-34, 35-44"

Genders

Looking at gender, authors can be identified as male, female or unknown (when a user hasn't specified this information). Here you'll be working with the fb.author.gender and fb.parent.author.gender targets.

To filter to a specific gender:

fb.author.gender == "male"

To exclude a gender:

fb.author.gender != "unknown"

You can of course combine multiple conditions, such as to look for males between 35 & 44:

fb.author.age == "35-44" AND fb.author.gender == "male"

Filtering by location

When working with location there a few targets you can work with:

To filter to a certain country you could write a filter like so:

fb.author.country == "United States"

Or you could use country codes instead:

fb.author.country_code == "US"

To filter to a list of countries:

fb.author.country_code in "US,UK"

To filter to regions:

fb.author.region in "New York,California"

You could of course combine any of the above conditions with logical operators to create tighter filters.

Equally you can make use of the country_region targets, for example you could filter to England in the UK. (These targets can be useful when there are regions with the same name in different countries you are trying to distinguish between.)

fb.author.country_region in "United Kingdom|England"

Filtering by author type

Authors on Facebook are either users or pages. You can distinguish between the two using the fb.author.type and fb.parent.author.type targets.

To filter to just users:

fb.author.type == "user"

To exclude a type:

fb.author.type != "page"