Facebook Ads: Query Builder

In this article, we will create a custom query using the Facebook Ads Query Builder in order to highlight the features and functionality of the tool. For this example, we will be creating a new metric that will give us the reach value sorted by region from a selected campaign.

IN THIS ARTICLE

1. Basic Options

A
  Custom Query Name: Create a name for your custom query in this field. You will find this name/title as a metric option in the designer after saving the query.
We chose "Reach by Region / Likes Campaign" for our query name.
B
  Metric (required) : Select a metric from your connected Facebook Ads data source such as users, reach, actions, clicks, impressions, etc. A metric can be used in conjunction with dimensions.
You can find more information about metrics here.
C
  Dimensions (optional) The dimensions parameter breaks down metrics by common criteria ('Breakdowns' in Facebook Ads), such as by gender or region (like in our example). When dimensions are requested, values are segmented by the dimension value. If a query has no dimensions parameter, the returned metrics will provide aggregate values for the requested date range, such as overall reach.
You can find more information about dimensions / breakdowns here.
D
  Date range (required) To display your data the way you like, you will need to choose time intervals. Just click on the "Date range" field. Selected intervals will be enabled for a new metric.
E
 Compare With (optional) : Select a date range to compare your previously selected interval to. This date range will be used for "previous line" on line and bar charts, and for calculating change %. Options are: None, Previous period and Same period last year.

2. Advanced Options

In our example, we set filters in order to retrieve data only for certain regions (specified by the 'dimension') from a campaign named "Likes" in the US with more than 500 impressions. 
F
  Filter by (optional) : You can filter results by dimensions or by specific metrics. Filters can be combined using the  AND boolean logic. Filtered queries restrict the rows that do (or do not) get included in the result. Each row in the result is tested against the filter. If the filter matches, the row is retained. If it doesn't match, the row is dropped.

Filter Operators

Dimension Filters:

  • Contains: Aggregate metrics where the country contains US
  • Does not contain: Aggregate metrics where the country does not contain US

Metric Filters:

  • Equals: Return results for regions where number of impressions is exactly 500
  • Does not equal: Return results for regions where number of impressions is not 500
  • Greater than: Return results for regions where number of impressions is strictly greater than 500
  • Less than: Return results for regions where number of impressions is strictly less than 500
  • Greater than or equal to: Return results for regions where number of impressions is 500 or more
  • Less than or equal to: Return results for regions where number of impressions is 500 or less
When everything mentioned above is set, click "Run query" to show  Data preview.

3. Data preview

In Data Preview you will see all values for selected metrics and date ranges. At the bottom you can check total values. Just click on tabs to switch between date ranges.

If you want to sort values by date/time just click on the arrow next to "Date"

When your query is ready, click "Save query." This creates a metric in Databox, with the metric name the same as the custom query name (Reach by Region / Likes Campaign).

By default, a metric will be added within the data source that the data is pulled from. It is possible to change the target data source by clicking on "Change target data source" in the top right of the screen.

Transformations

Rename Dimension:

It is possible to rename dimensions. Best practice is to rename them before saving the query. You can do this by clicking  "..." next to "Dimension" and then selecting "Rename dimension"

Skip Dimension:

This function is useful when you want to exclude one or more dimensions. For example, this would be useful if you want to show data for all regions except one. Click  "..." next to "Dimension" and select "Skip dimension"

Round values:

Click  "..." next to "Value" and select "Round values." Enter the number of decimal places to be rounded to into field in popup, and values will be rounded accordingly.

Still need help? Contact Us Contact Us