Example Nested Queries

Nested queries are powerful as they allow you to perform in-depth analysis in one API call that would require many individual calls with simple queries.

For a detailed example of a nested query take a look at our nested query example page.

To understand what combinations of targets you can use see our Analysis Using Nested Queries guide.

On this page we'll take a look at some example queries you can carry out to get some great insights from your recordings.

What is the age and gender composition of my audience?

To create an age-gender breakdown of your audience you can first split your audience by gender using the fb.author.gender target then analyze the resulting gender groups using the fb.author.age target.

Top-level analysis target fb.author.gender
1st child analysis target fb.author.age
Analysis parameters
{
  "analysis_type": "freqDist",
  "parameters": {
    "target": "fb.author.gender",
    "threshold": 2
  },
  "child": {
    "analysis_type": "freqDist",
    "parameters": {
      "target": "fb.author.age",
      "threshold": 6
    }
  }
}
Example visualisation

How do audiences compare across brands, topics or features?

You can extend the above example by adding a level above as a new parent target.

In this example we'll use hashtags to represent topics of conversation, represented by the fb.hashtags target. However you could equally use topics or your own custom tags for the top level of the query.

Top-level analysis target fb.hashtags
1st child analysis target fb.author.gender
2nd child analysis target fb.author.age
Analysis parameters
{
  "analysis_type": "freqDist",
  "parameters": {
    "target": "fb.hashtags",
    "threshold": 2
  },
  "child": {
    "analysis_type": "freqDist",
    "parameters": {
      "target": "fb.author.gender",
      "threshold": 2
    },
    "child": {
      "analysis_type": "freqDist",
      "parameters": {
        "target": "fb.author.age",
        "threshold": 6
      }
    }
  }
}
Example visualisation

How does an audience interact with brands, topics or themes?

You can use tags to identify brand mentions by audiences. For example you could add the following tags to identify automotive brands:

tag.automotive.brand "BMW" { fb.parent.content contains_any "BMW" or fb.content contains_any "BMW" } 
tag.automotive.brand "Honda" { fb.parent.content contains_any "Honda" or fb.content contains_any "Honda" } 
tag.automotive.brand "Ford" { fb.parent.content contains_any "Ford" or fb.content contains_any "Ford" }

With these tags added to a filter we can analyze the recorded data using the interaction.tag_tree target.

First we'll split the audience by brand using the interaction.tag_tree target and then analyze types of interaction using the fb.type target.

Top-level analysis target interaction.tag_tree
1st child analysis target fb.type
Analysis parameters
{
  "analysis_type": "freqDist",
  "parameters": {
    "target": "interaction.tag_tree.automotive.brand",
    "threshold": 3
  },
  "child": {
    "analysis_type": "freqDist",
    "parameters": {
      "target": "fb.type",
      "threshold": 4
    }
  }
}
Example visualisation

Which gender interactions or engages most with shared content?

To create a link versus gender breakdown of your audience you can first split your audience by gender using the links.url target (as this is a high cardinality target so needs to be the parent) then analyze the resulting links using the fb.author.gender target (which will include stories and engagements).

Top-level analysis target links.url
1st child analysis target fb.author.gender
Analysis parameters
{
  "analysis_type": "freqDist",
  "parameters": {
    "target": "links.url",
    "threshold": 5
  },
  "child": {
    "analysis_type": "freqDist",
    "parameters": {
      "target": "fb.author.gender",
      "threshold": 2
    }
  }
}
Example visualisation

How does engagement vary depending on what type of author posted a story?

It's interesting to see how audiences engage with content that's created by users versus content created by brands and organisations ('page' type users). First split your audience by author type using the fb.parent.author.type target (note that because this target is only present on engagements this immediately removes stories from the analysis) then analyze the resulting groups using the fb.type target.

Top-level analysis target fb.parent.author.type
1st child analysis target fb.type
Analysis parameters
{
  "analysis_type": "freqDist",
  "parameters": {
    "target": "fb.parent.author.type",
    "threshold": 2
  },
  "child": {
    "analysis_type": "freqDist",
    "parameters": {
      "target": "fb.type",
      "threshold": 4
    }
  }
}
Example visualisation

How does hashtag usage vary between types of author?

It's interesting to understand which types of author (users versus pages) are creating stories using hashtags. First split your data set using the fb.hashtags target (note engagements do not have this target so are therefore excluded) then analyze the resulting groups using the fb.author.type target.

Top-level analysis target fb.hashtags
1st child analysis target fb.author.type
Analysis parameters
{
  "analysis_type": "freqDist",
  "parameters": {
    "target": "fb.hashtags",
    "threshold": 3
  },
  "child": {
    "analysis_type": "freqDist",
    "parameters": {
      "target": "fb.author.type",
      "threshold": 2
    }
  }
}
Example visualisation

How does gender of audiences engaging vary by region?

To analyze gender engagement across regions first split your audience by gender using the fb.author.region target (this will break stories and engagements in to region groups) then analyze the resulting groups using the fb.parent.author.gender target (this will restrict data to just engagements as stories do not have the fb.parent.* targets).

Top-level analysis target fb.author.region
1st child analysis target fb.parent.author.gender
Analysis parameters
{
  "analysis_type": "freqDist",
  "parameters": {
    "target": "fb.author.region",
    "threshold": 31
  },
  "child": {
    "analysis_type": "freqDist",
    "parameters": {
      "target": "fb.parent.author.gender",
      "threshold": 2
    }
  }
}
Example visualisation

How does sentiment of stories posted vary by country?

To analyze how sentiment varies across countries first split your audience by country using the fb.author.country target (note this needs to be the parent as it is a high cardinality target) then analyze the resulting country groups using the fb.sentiment target (note this will restrict the data set to stories only as engagements do not have this target).

Top-level analysis target fb.author.country
1st child analysis target fb.sentiment
Analysis parameters
{
  "analysis_type": "freqDist",
  "parameters": {
    "target": "fb.author.country",
    "threshold": 5
  },
  "child": {
    "analysis_type": "freqDist",
    "parameters": {
      "target": "fb.sentiment",
      "threshold": 2
    }
  }
}
Example visualisation