You can connect Facebook Page Insights connector to import the following Facebook data into Treasure Data:


Prerequisites

  • Basic knowledge of Treasure Data

  • Basic knowledge of Facebook Graph API

  • Having required permissions for downloading Facebook Page data.

  • Authorized Treasure Data account access

Using TD Console to Create Your Connection

Create a New Authentication

Go to Integrations Hub > Catalog. Search and select Facebook Page Insights. A dialog will open.

Select an existing OAuth connection for Facebook, or select the link under OAuth connection to create a new connection.


Create a New OAuth Connection

Login to your Facebook account in a popup window:

And grant access to Treasure Data app.

You will be redirected back to the TD Console. Repeat the first step (Create a new authentication) and choose your new OAuth connection.

Name your new authentication. Select Done.

Transfer Your Facebook Insights Data to Treasure Data

In Authentications, configure the New Source.

Connection

In this dialog, you can name the Source by editing the Data Transfer Name.

  1. Name the Source in the Data Transfer field.

  2. Select Next. The Source Table dialog opens.

Source Table

In Source Table, edit the parameters and select Next.


Parameter

Description

Data Type

Supported data types:

  • Page

  • Post

  • Video

  • Conversation Messages

  • Conversation Participants

  • Comments

Folders(s)

Conversation folders


For the data type Video, the only period supported is Lifetime.

Data Settings

In this dialog, you can edit data settings or opt to skip this step.

  1. Edit the Data Settings parameters.

  2. Select Next.

Parameters

Description

Retrieve Video insights back to

Due to Facebook-specified data limits, a job may fail to retrieve all past data. The default setting is to import the last 3 months of data for Video Insights. Update this value to import more data.

Skip Error POST

Default true. Skip error when importing POST Insights when an error occurred.

Retry Limit

The number of retries before the connector stops trying to connect and retrieve data.

Retry initial wait in millis

Interval to retry if a recoverable error happens (in millisecond).

Max retry wait in millis

Maximum time in milliseconds between retry attempts.

HTTP connect timeout in millis

Http connection timeout

HTTP idle timeout in millis

Http idle timeout

Data Preview 

You can see a preview of your data before running the import by selecting Generate Preview. You can opt to skip this step.

  1. Select Generate Preview.

  2. After the preview is generated and you have verified it is the correct data, select Next.

Data Placement

In this dialog, you will specify where your data will be placed and schedule how often it will run this import.


Under Storage you will create a new or select an existing database and create a new or select an existing table for where you want to place the imported data.

  1. Select a Database > Select an existing or Create New Database.

  2. Select a Table> Select an existing or Create New Table.

  3. Choose the Append or Replace method for importing the data.

    • Append (default)-Data import results are appended to the table. If the table does not exist, it will be created.

    • Replace-Replaces the entire content of an existing table with the resulting output of the query. If the table does not exist, a new table is created. 

  4. Select the Timestamp-based Partition Key column. If you want to set a different partition key seed than the default key, you can specify the long or timestamp column as the partitioning time. As a default time column, it uses upload_time with the add_time filter.

  5. Select the Timezone for your data storage.

 Under Schedule, you can choose when and how often you want to run this query.

  •  Run once:

    1. Select Off.

    2. Select Scheduling Timezone.

    3. Select Create & Run Now.

  • Repeat the query:

    1. Select On.

    2. Select the Schedule. The UI provides these four options: @hourly, @daily and @monthly or custom cron.

    3. You can also select Delay Transfer and add a delay of execution time.

    4. Select Scheduling Timezone.

    5. Select Create & Run Now.

After your transfer has run, you can see the results of your transfer in Data Workbench > Databases.

Use Command-Line to Create Your Facebook Connection

You can use the Treasure Data Console to configure your connection.

Install the Treasure Data Toolbelt

Open a terminal and run the following command to install the newest TD Toolbelt.

Obtain a Facebook Token

Facebook provides 3 types of tokens. You will need the Page Access Token. We recommend that you select the never-expiring Page Access Token.

To obtain the never-expiring Page Access Token, follow the instructions here: https://www.rocketmarketinginc.com/blog/get-never-expiring-facebook-page-access-token/

Prepare a Configuration File (config.yml)

Using a text editor, create a file called config.yml. Copy and paste the following information replacing the placeholder text with your Facebook connector info.

The in: section is where you specify what comes into the connector from Facebook and the out: section is where you specify what the connector puts out to the database in Treasure Data. For more details on available out: modes, see Appendix.

in:
  type: "facebook_page_insights"
  access_token: "[your Facebook Page token]"
  page_id: [your Facebook Page ID]
  data_type: page
  incremental: true
  select_all_metrics: true
  since: 2017-01-01
  until: 2017-01-31
out:
  mode: append

Configuration keys and descriptions are as follows:


Option name

Description

Type

Required?

Default Value

access_token

Facebook Page Access Token. 

string

yes

page_id

Facebook Page ID. See Addendum

string

yes

data_type

  • page

  • post

  • video

  • conversation_message

  • conversation_participant

  • comment

string

optional

page

select_all_metrics

Import all supported insight metrics for the current Data Type. Set this value so you don't need to set metric_presets or metrics. Applicable for Page and Post. See Available Metrics.

 bool

 optional


metric_presets

Predefined category of metrics, or group of related metrics. See Supported Preset Metrics.

array

optional

metrics

Facebook Graph insight metrics, you can specify each metric, as much as you need. This config will override metric_preset if both of them are specified. Supported Metrics

array

optional

since

Lower bound of the time range to consider, supported formats: yyyy-MM-dd or Unix time i.e. 1584697547

string

optional

until

Upper bound of the time range to consider, supported formats: yyyy-MM-dd or Unix time i.e. 1584697547

string

optional

period

The aggregation period. See Supported Periods.

enum

optional

date_preset

Preset a date range, like ‘lastweek’ or ‘yesterday’. If a ‘since’ or ‘until’ date is specified and the date_preset is also selected, the data transfer request will fail. See Supported Date Presets.

enum

optional

incremental

true for generate “config_diff” with embulk run -c config.diff

bool

optional

false

last_in_months

Retrieve Video insights back to this months range. Specify more than 3 months range would cause the job error due to Facebook API limitation.

integer 

optional

3 (months)

skip_error_post

Skip error when importing POST insights 

bool

optional 

 true

retry_limit

Number of error retries before connector gives up

integer

optional

7

retry_initial_wait_millis

Wait milliseconds for exponential backoff initial value

integer

optional

500 (0.5 second)

max_retry_wait_millis

Maximum wait milliseconds for each retry

integer

optional

300000 (5 minutes)

connect_timeout_millis

HTTP connect timeout in milliseconds

integer

optional

180000 (3 minutes)

idle_timeout_millis

HTTP idle timeout in milliseconds

integer

optional

300000 (5 minutes)

conversation_folders

Conversation folder: inbox, page_done, other, pending and spam

E.g. [{"value":"inbox"}] 

 array

optional

all folders


Example of config.yml with incremental and Page data type

in:
  type: "facebook_page_insights"
  access_token: "[your Facebook Page token]"
  page_id: [your Facebook Page ID]
  data_type: page
  page_metric_presets:
  - value: page_impressions
  - value: page_cta_clicks
  - value: page_user_demographics
  - value: page_views
  - value: page_engagement
  incremental: true
  since: 2017-01-01
  until: 2017-01-31
out:
  mode: append

Post data type

in:
  type: "facebook_page_insights"
  access_token: "[your Facebook Page token]"
  page_id: [your Facebook Page ID]
  data_type: post
  post_metric_presets:
  - value: page_post_impressions
  - value: page_post_engagement
  - value: page_post_reactions
  - value: page_video_posts
  since: 2017-01-01
  until: 2017-01-31
out:
  mode: append

Video data type

in:
  type: "facebook_page_insights"
  access_token: "[your Facebook Page token]"
  page_id: [your Facebook Page ID]
  data_type: video
  last_in_months: 3
out:
  mode: append

Preview the Data to be Imported (Optional)

You can preview data to be imported using the command td connector:preview.

$ td connector:preview config.yml
+---------------------------+-------------------------+--------------------------------+------------------------------+----------------------------------+------------------------------------+------------------------+-------------------------------+--------------------------------+-----------------------------------+-----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+---------------------------+----------------------------------+---------------------------------------------------------------------+
| end_time:timestamp        | lifetime_page_fans:json | lifetime_page_fans_locale:json | lifetime_page_fans_city:json | lifetime_page_fans_country:json  | lifetime_page_fans_gender_age:json | day_page_fan_adds:json | day_page_fan_adds_unique:json | week_page_fan_adds_unique:json | days_28_page_fan_adds_unique:json | day_page_fans_by_like_source:json                                                 | day_page_fans_by_like_source_unique:json                                          | day_page_fans_group_by_like_source_unique:json                                | day_page_fan_removes:json | day_page_fan_removes_unique:json | day_page_fans_by_unlike_source_unique:json                          |
+---------------------------+-------------------------+--------------------------------+------------------------------+----------------------------------+------------------------------------+------------------------+-------------------------------+--------------------------------+-----------------------------------+-----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+---------------------------+----------------------------------+---------------------------------------------------------------------+
| "2017-01-11 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "5"                    | "5"                           | "29"                           | "122"                             | "{\"sponsored_story\":5}"                                                         | "{\"sponsored_story\":5}"                                                         | "{\"Ads\":5}"                                                                 | "0"                       | "0"                              | nil                                                                 |
| "2017-01-03 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "7"                    | "7"                           | "32"                           | "122"                             | "{\"feed_story\":1,\"sponsored_story\":6}"                                        | "{\"feed_story\":1,\"sponsored_story\":6}"                                        | "{\"Uncategorized Desktop\":1,\"Ads\":6}"                                     | "1"                       | "1"                              | "{\"pagelike_deleter_for_deactivated_users\":1}"                    |
| "2017-01-04 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "5"                    | "5"                           | "29"                           | "125"                             | "{\"sponsored_story\":1,\"page_profile\":1,\"page_timeline\":2,\"hovercard\":1}"  | "{\"sponsored_story\":1,\"page_profile\":1,\"page_timeline\":2,\"hovercard\":1}"  | "{\"On Your Page\":1,\"Your Posts\":1,\"Uncategorized Desktop\":2,\"Ads\":1}" | "1"                       | "1"                              | "{\"normal_unfan\":1}"                                              |
| "2017-01-10 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "6"                    | "6"                           | "29"                           | "117"                             | "{\"feed_story\":1,\"sponsored_story\":3,\"page_profile\":1,\"page_timeline\":1}" | "{\"feed_story\":1,\"sponsored_story\":3,\"page_profile\":1,\"page_timeline\":1}" | "{\"On Your Page\":1,\"Uncategorized Desktop\":2,\"Ads\":3}"                  | "0"                       | "0"                              | nil                                                                 |
| "2017-01-09 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "3"                    | "3"                           | "30"                           | "117"                             | "{\"pagelike_adder_for_reactivated_users\":1,\"page_timeline\":2}"                | "{\"pagelike_adder_for_reactivated_users\":1,\"page_timeline\":2}"                | "{\"Uncategorized Desktop\":3}"                                               | "0"                       | "0"                              | nil                                                                 |
| "2017-01-02 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "4"                    | "4"                           | "28"                           | "120"                             | "{\"sponsored_story\":3,\"timeline_like_chaining\":1}"                            | "{\"sponsored_story\":3,\"timeline_like_chaining\":1}"                            | "{\"Uncategorized Desktop\":1,\"Ads\":3}"                                     | "0"                       | "0"                              | nil                                                                 |
| "2017-01-16 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "7"                    | "7"                           | "40"                           | "118"                             | "{\"feed_story\":2,\"sponsored_story\":3,\"page_profile\":2}"                     | "{\"feed_story\":2,\"sponsored_story\":3,\"page_profile\":2}"                     | "{\"On Your Page\":2,\"Uncategorized Desktop\":2,\"Ads\":3}"                  | "4"                       | "2"                              | "{\"normal_unfan\":2}"                                              |
| "2017-01-06 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "2"                    | "2"                           | "31"                           | "117"                             | "{\"feed_story\":1,\"sponsored_story\":1}"                                        | "{\"feed_story\":1,\"sponsored_story\":1}"                                        | "{\"Uncategorized Desktop\":1,\"Ads\":1}"                                     | "0"                       | "0"                              | nil                                                                 |
| "2017-01-14 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "1"                    | "1"                           | "27"                           | "107"                             | "{\"feed_story\":1}"                                                              | "{\"feed_story\":1}"                                                              | "{\"Uncategorized Desktop\":1}"                                               | "0"                       | "0"                              | nil                                                                 |
| "2017-01-15 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "11"                   | "11"                          | "36"                           | "116"                             | "{\"feed_story\":1,\"sponsored_story\":6,\"page_profile\":3,\"search\":1}"        | "{\"feed_story\":1,\"sponsored_story\":6,\"page_profile\":3,\"search\":1}"        | "{\"On Your Page\":3,\"Search\":1,\"Uncategorized Desktop\":1,\"Ads\":6}"     | "1"                       | "1"                              | "{\"pagelike_deleter_for_deactivated_users\":1}"                    |
| "2017-01-05 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "5"                    | "5"                           | "29"                           | "120"                             | "{\"feed_story\":3,\"sponsored_story\":1,\"page_timeline\":1}"                    | "{\"feed_story\":3,\"sponsored_story\":1,\"page_timeline\":1}"                    | "{\"Uncategorized Desktop\":4,\"Ads\":1}"                                     | "2"                       | "2"                              | "{\"pagelike_deleter_for_deactivated_users\":1,\"normal_unfan\":1}" |
| "2017-01-08 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "2"                    | "2"                           | "31"                           | "120"                             | "{\"feed_story\":2}"                                                              | "{\"feed_story\":2}"                                                              | "{\"Uncategorized Desktop\":2}"                                               | "1"                       | "1"                              | "{\"normal_unfan\":1}"                                              |
| "2017-01-07 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "6"                    | "6"                           | "35"                           | "118"                             | "{\"feed_story\":1,\"sponsored_story\":2,\"page_profile\":2,\"page_timeline\":1}" | "{\"feed_story\":1,\"sponsored_story\":2,\"page_profile\":2,\"page_timeline\":1}" | "{\"On Your Page\":2,\"Uncategorized Desktop\":2,\"Ads\":2}"                  | "0"                       | "0"                              | nil                                                                 |
| "2017-01-12 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "7"                    | "7"                           | "30"                           | "125"                             | "{\"feed_story\":1,\"sponsored_story\":5,\"hovercard\":1}"                        | "{\"feed_story\":1,\"sponsored_story\":5,\"hovercard\":1}"                        | "{\"Your Posts\":1,\"Uncategorized Desktop\":1,\"Ads\":5}"                    | "0"                       | "0"                              | nil                                                                 |
| "2017-01-13 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "4"                    | "4"                           | "32"                           | "115"                             | "{\"feed_story\":1,\"sponsored_story\":3}"                                        | "{\"feed_story\":1,\"sponsored_story\":3}"                                        | "{\"Uncategorized Desktop\":1,\"Ads\":3}"                                     | "2"                       | "1"                              | "{\"normal_unfan\":1}"                                              |
+---------------------------+-------------------------+--------------------------------+------------------------------+----------------------------------+------------------------------------+------------------------+-------------------------------+--------------------------------+-----------------------------------+-----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+---------------------------+----------------------------------+---------------------------------------------------------------------+
15 rows in set

Execute Load Job

You must specify the database and table where you want to store the data before you execute the load job.

You use td connector:issue to execute the job. The following are required: the name of the schedule, the cron-style schedule, the database and table where their data will be stored, and the Data Connector configuration file.

$ td connector:issue config.yml --database td_sample_db --table td_sample_table

It is recommended to specify --time-column option because Treasure Data’s storage is partitioned by time. You can also use the --time-column option to override auto-generated time values, by specifying end_time as the time column (only applied for data_typepage). Data will be accumulated daily and end_time will be end of the day, using the timezone of your Facebook Page, but converted to UTC format.

If your data doesn’t have a time column, you can add the column by using the add_time filter option. See details at add_time Filter Plugin for Integrations.

Finally, submit the load job. It may take a couple of hours depending on the data size. You must specify the database and table where their data is stored.

$ td connector:issue config.yml --database td_sample_db --table
td_sample_table --time-column end_time

Scheduled Execution

You can schedule periodic data connector execution for incremental Facebook Insights data. We configure our scheduler carefully to ensure high availability. By using this feature, you no longer need a cron daemon on your local data center.

For the scheduled import, at first run, the Data Connector for Facebook Page Insights imports all of your ad data.

On the second and subsequent runs, the connector imports only data that is newer than the last load.

Create the Schedule

A new schedule can be created using the td connector:create command. The following are required: the name of the schedule, the cron-style schedule, the database and table where their data will be stored, and the data connector configuration file.

$ td connector:create \
    daily_import \
    "10 0 * * *" \
    td_sample_db \
    td_sample_table \
    config.yml

The `cron` parameter also accepts three special options: `@hourly`, `@daily` and `@monthly`.

By default, the schedule is setup in UTC timezone. You can set the schedule in a timezone using -t or --timezone option. Note that the `--timezone` option supports only extended timezone formats like 'Asia/Tokyo', 'America/Los_Angeles' etc. Timezone abbreviations like PST, CST are *not* supported and may lead to unexpected schedules.

List All Schedules

You can see the list of all current schedule entries with the command td connector:list.

$ td connector:list
+--------------+------------+----------+-------+--------------+-----------------+----------------------------+
| Name         | Cron       | Timezone | Delay | Database     | Table           | Config                     |
+--------------+------------+----------+-------+--------------+-----------------+----------------------------+
| daily_import | 10 0 * * * | UTC      | 0     | td_sample_db | td_sample_table | {"in"=>{"type"=>"fac", ... |
+--------------+------------+----------+-------+--------------+-----------------+----------------------------+

Show Schedule Settings and History

td connector:show shows the execution settings of a schedule entry.

% td connector:show daily_import
Name     : daily_import
Cron     : 10 0 * * *
Timezone : UTC
Delay    : 0
Database : td_sample_db
Table    : td_sample_table
Config
---
in:
  type: "facebook_page_insights"
  access_token: "[your Facebook Page token]"
  page_id: [your Facebook Page ID]
  data_type: page
  metric_presets:
  - page_impressions
  date_preset: last_7d
out:
  mode: append

td connector:history shows the execution history of a schedule entry. To investigate the results of each individual run, use td job <jobid>.

% td connector:history daily_import
+--------+---------+---------+--------------+-----------------+----------+---------------------------+----------+
| JobID  | Status  | Records | Database     | Table           | Priority | Started                   | Duration |
+--------+---------+---------+--------------+-----------------+----------+---------------------------+----------+
| 578066 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-18 00:10:05 +0000 | 160      |
| 577968 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-17 00:10:07 +0000 | 161      |
| 577914 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-16 00:10:03 +0000 | 152      |
| 577872 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-15 00:10:04 +0000 | 163      |
| 577810 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-14 00:10:04 +0000 | 164      |
| 577766 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-13 00:10:04 +0000 | 155      |
| 577710 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-12 00:10:05 +0000 | 156      |
| 577610 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-11 00:10:04 +0000 | 157      |
+--------+---------+---------+--------------+-----------------+----------+---------------------------+----------+
8 rows in set

Delete Schedule

td connector:delete removes the schedule.

$ td connector:delete daily_import

FAQ

Q: Why were my scheduled jobs categorized as "SUCCESS" but did not bring in new data?

2018-05-06 13:00:18.627 +0000 [WARN] (0047:task-0043): Time range does not reach, abort and will retry later. Start Date: '1525330800', End Date: '1528095600', Current Date: '2018-05-06'

This means either ‘Start Date’ or ‘End Date’ has exceeded the current date, for example, is specified with a date in the future. The cause of such warning messages could be that you’ve configured cron shorter than the fetching time range. For example, a daily job to pull monthly data.

Q: How can I set up daily jobs to pull in new data each time?

You need an initial load (or multiple loads, due to the limitation of a 3-month time range for each load). Let’s say today is 2018-05-09, and you need to load data since 2018-01-01:

Jobs

Start Date

End Date

First job (one-time)

2018-01-01

2018-04-01

Second job (one-time)

2018-04-01

2018-05-08

[Incremental] Daily job

2018-05-08

2018-05-09

Q: Why do I suddenly have so many Posts Insights data?

Started from version v0.2.0 you will get the insights of all Posts since the very first Post of the page until the End Date value. In this kaizen, we upgraded the date setting so you will be able to get the Insights data from Start Date to End Date of all available Posts. Compared to the version v0.1.16, you can only get the insights data from Start Date to End Date of the Posts created within that date range only.

Appendix

Modes for Out Plugin

You can specify file import mode in out section of config.yml.

append (default)

This is the default mode and records are appended to the target table.

in:
  ...
out:
  mode: append

replace

This mode replaces data in the target table. Any manual schema changes made to the target table remains intact with this mode.

in:
  ...
out:
  mode: replace

How Data Aggregated

Result data will be aggregated by the end of each day, meaning insights of 2017-01-01 will have end_time = 2017-01-02 00:00:00.

Facebook APIs and other Facebook interfaces vary in how Start date and End dates are defined. The Start and End date you specify while defining this connector is passed to the Facebook API that you specify. You might need to adjust the Start and End dates that you specify to ensure that, within Facebook, the various API and interface Start and End dates match.

If you use Incremental Loading and scheduled jobs, the time range for the next iteration (run) will be calculated based on the initial Start Date and End Date. Imported data will have no gaps.

Due to the way Facebook API query operates, you will need to pay attention to End Date if you’re running a one-time job.

Your result will include insights data with end_time spanning from <Start Date + 1> 00:00:00 to <End Date - 1> 00:00:00.

If you want to import the insights for the month of January 2017, the End Date must be used carefully. For example, if you chose the Start Date and End Date this way:

  • Start Date = 2017-01-01 (or 2017-01-01 00:00:00)

  • End Date = 2017-02-01 (or 2017-02-01 00:00:00)

Your output will look similar to the following example:

+---------------------------+-------------------------+--------------------------------+------------------------------+----------------------------------+------------------------------------+------------------------+-------------------------------+--------------------------------+-----------------------------------+-----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+---------------------------+----------------------------------+---------------------------------------------------------------------+
| end_time:timestamp        | lifetime_page_fans:json | lifetime_page_fans_locale:json | lifetime_page_fans_city:json | lifetime_page_fans_country:json  | lifetime_page_fans_gender_age:json | day_page_fan_adds:json | day_page_fan_adds_unique:json | week_page_fan_adds_unique:json | days_28_page_fan_adds_unique:json | day_page_fans_by_like_source:json                                                 | day_page_fans_by_like_source_unique:json                                          | day_page_fans_group_by_like_source_unique:json                                | day_page_fan_removes:json | day_page_fan_removes_unique:json | day_page_fans_by_unlike_source_unique:json                          |
+---------------------------+-------------------------+--------------------------------+------------------------------+----------------------------------+------------------------------------+------------------------+-------------------------------+--------------------------------+-----------------------------------+-----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+---------------------------+----------------------------------+---------------------------------------------------------------------+
| "2017-01-02 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "5"                    | "5"                           | "29"                           | "122"                             | "{\"sponsored_story\":5}"                                                         | "{\"sponsored_story\":5}"                                                         | "{\"Ads\":5}"                                                                 | "0"                       | "0"                              | nil                                                                 |
| "2017-01-03 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "7"                    | "7"                           | "32"                           | "122"                             | "{\"feed_story\":1,\"sponsored_story\":6}"                                        | "{\"feed_story\":1,\"sponsored_story\":6}"                                        | "{\"Uncategorized Desktop\":1,\"Ads\":6}"                                     | "1"                       | "1"                              | "{\"pagelike_deleter_for_deactivated_users\":1}"                    |
| ...                       | ...                     | ...                            | ...                          | ...                              | ...                                | ...                    | ...                           | ...                            | ...                               | ...                                                                               | ...                                                                               | ...                                                                           | ...                       | ...                              | ...                                                                 |
| "2017-01-30 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "7"                    | "7"                           | "30"                           | "125"                             | "{\"feed_story\":1,\"sponsored_story\":5,\"hovercard\":1}"                        | "{\"feed_story\":1,\"sponsored_story\":5,\"hovercard\":1}"                        | "{\"Your Posts\":1,\"Uncategorized Desktop\":1,\"Ads\":5}"                    | "0"                       | "0"                              | nil                                                                 |
| "2017-01-31 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "4"                    | "4"                           | "32"                           | "115"                             | "{\"feed_story\":1,\"sponsored_story\":3}"                                        | "{\"feed_story\":1,\"sponsored_story\":3}"                                        | "{\"Uncategorized Desktop\":1,\"Ads\":3}"                                     | "2"                       | "1"                              | "{\"normal_unfan\":1}"                                              |
+---------------------------+-------------------------+--------------------------------+------------------------------+----------------------------------+------------------------------------+------------------------+-------------------------------+--------------------------------+-----------------------------------+-----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+---------------------------+----------------------------------+---------------------------------------------------------------------+

The result contains data up to and including Jan 30th, ending with the beginning of Jan 31st, but will include no data for Jan 31st. To get data for the entire month, you must set End Date = 2017-02-02:

+---------------------------+-------------------------+--------------------------------+------------------------------+----------------------------------+------------------------------------+------------------------+-------------------------------+--------------------------------+-----------------------------------+-----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+---------------------------+----------------------------------+---------------------------------------------------------------------+
| end_time:timestamp        | lifetime_page_fans:json | lifetime_page_fans_locale:json | lifetime_page_fans_city:json | lifetime_page_fans_country:json  | lifetime_page_fans_gender_age:json | day_page_fan_adds:json | day_page_fan_adds_unique:json | week_page_fan_adds_unique:json | days_28_page_fan_adds_unique:json | day_page_fans_by_like_source:json                                                 | day_page_fans_by_like_source_unique:json                                          | day_page_fans_group_by_like_source_unique:json                                | day_page_fan_removes:json | day_page_fan_removes_unique:json | day_page_fans_by_unlike_source_unique:json                          |
+---------------------------+-------------------------+--------------------------------+------------------------------+----------------------------------+------------------------------------+------------------------+-------------------------------+--------------------------------+-----------------------------------+-----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+---------------------------+----------------------------------+---------------------------------------------------------------------+
| "2017-01-02 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "5"                    | "5"                           | "29"                           | "122"                             | "{\"sponsored_story\":5}"                                                         | "{\"sponsored_story\":5}"                                                         | "{\"Ads\":5}"                                                                 | "0"                       | "0"                              | nil                                                                 |
| "2017-01-03 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "7"                    | "7"                           | "32"                           | "122"                             | "{\"feed_story\":1,\"sponsored_story\":6}"                                        | "{\"feed_story\":1,\"sponsored_story\":6}"                                        | "{\"Uncategorized Desktop\":1,\"Ads\":6}"                                     | "1"                       | "1"                              | "{\"pagelike_deleter_for_deactivated_users\":1}"                    |
| ...                       | ...                     | ...                            | ...                          | ...                              | ...                                | ...                    | ...                           | ...                            | ...                               | ...                                                                               | ...                                                                               | ...                                                                           | ...                       | ...                              | ...                                                                 |
| "2017-01-31 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "7"                    | "7"                           | "30"                           | "125"                             | "{\"feed_story\":1,\"sponsored_story\":5,\"hovercard\":1}"                        | "{\"feed_story\":1,\"sponsored_story\":5,\"hovercard\":1}"                        | "{\"Your Posts\":1,\"Uncategorized Desktop\":1,\"Ads\":5}"                    | "0"                       | "0"                              | nil                                                                 |
| "2017-02-01 08:00:00 UTC" | "1234"                  | "{}"                           | "{}"                         | "{}"                             | "{}"                               | "4"                    | "4"                           | "32"                           | "115"                             | "{\"feed_story\":1,\"sponsored_story\":3}"                                        | "{\"feed_story\":1,\"sponsored_story\":3}"                                        | "{\"Uncategorized Desktop\":1,\"Ads\":3}"                                     | "2"                       | "1"                              | "{\"normal_unfan\":1}"                                              |
+---------------------------+-------------------------+--------------------------------+------------------------------+----------------------------------+------------------------------------+------------------------+-------------------------------+--------------------------------+-----------------------------------+-----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+---------------------------+----------------------------------+---------------------------------------------------------------------+


Supported Preset Metrics

Facebook’s Name

Data Type

Value to Use

Page Impressions

Page

page_impressions

Page Engagement

Page

page_engagement

Page CTA Clicks

Page

page_cta_clicks

Page User Demographics

Page

page_user_demographics

Page Views

Page

page_views

Page Reactions

Page

page_reactions

Page Video Views

Page

page_video_views

Page Post Impressions

Post

page_post_impressions

Page Post Engagement

Post

page_post_engagement

Page Post Reactions

Post

page_post_reactions

Page Video Posts

Post

page_video_posts

People Talking About This

Page, Post

people_talking_about_this

Supported Periods

  • day

  • week

  • days_28

  • month

  • lifetime

To import all periods, select all periods from the TD Console, or not set on TD CLI

Supported Date Presets

  • today

  • yesterday

  • this_month

  • last_month

  • this_quarter

  • lifetime

  • last_3d

  • last_7d

  • last_14d

  • last_28d

  • last_30d

  • last_90d

  • last_week_mon_sun

  • last_week_sun_sat

  • last_quarter

  • last_year

  • this_week_mon_today

  • this_week_sun_today

  • this_year

Supported Metrics

Page

  • page_impressions

  • page_impressions_unique

  • page_impressions_paid

  • page_impressions_paid_unique

  • page_impressions_organic

  • page_impressions_organic_unique

  • page_impressions_viral

  • page_impressions_viral_unique

  • page_impressions_by_story_type

  • page_impressions_by_story_type_unique

  • page_impressions_by_city_unique

  • page_impressions_by_country_unique

  • page_impressions_by_locale_unique

  • page_impressions_by_age_gender_unique

  • page_impressions_frequency_distribution

  • page_impressions_viral_frequency_distribution

  • page_total_actions

  • page_cta_clicks_logged_in_total

  • page_cta_clicks_logged_in_unique

  • page_cta_clicks_by_site_logged_in_unique

  • page_cta_clicks_by_age_gender_logged_in_unique

  • page_cta_clicks_logged_in_by_country_unique

  • page_cta_clicks_logged_in_by_city_unique

  • page_call_phone_clicks_logged_in_unique

  • page_call_phone_clicks_by_age_gender_logged_in_unique

  • page_call_phone_clicks_logged_in_by_country_unique

  • page_call_phone_clicks_logged_in_by_city_unique

  • page_call_phone_clicks_by_site_logged_in_unique

  • page_get_directions_clicks_logged_in_unique

  • page_get_directions_clicks_by_age_gender_logged_in_unique

  • page_get_directions_clicks_logged_in_by_country_unique

  • page_get_directions_clicks_logged_in_by_city_unique

  • page_get_directions_clicks_by_site_logged_in_unique

  • page_website_clicks_logged_in_unique

  • page_website_clicks_by_age_gender_logged_in_unique

  • page_website_clicks_logged_in_by_country_unique

  • page_website_clicks_logged_in_by_city_unique

  • page_website_clicks_by_site_logged_in_unique

  • page_fans

  • page_fans_locale

  • page_fans_city

  • page_fans_country

  • page_fans_gender_age

  • page_fan_adds

  • page_fan_adds_unique

  • page_fans_by_like_source

  • page_fans_by_like_source_unique

  • page_fan_removes

  • page_fan_removes_unique

  • page_fans_by_unlike_source_unique

  • page_views_total

  • page_views_logout

  • page_views_logged_in_total

  • page_views_logged_in_unique

  • page_views_external_referrals

  • page_views_by_profile_tab_total

  • page_views_by_profile_tab_logged_in_unique

  • page_views_by_internal_referer_logged_in_unique

  • page_views_by_site_logged_in_unique

  • page_views_by_age_gender_logged_in_unique

  • page_engaged_users

  • page_post_engagements

  • page_consumptions

  • page_consumptions_unique

  • page_consumptions_by_consumption_type

  • page_consumptions_by_consumption_type_unique

  • page_places_checkin_total

  • page_places_checkin_total_unique

  • page_places_checkin_mobile

  • page_places_checkin_mobile_unique

  • page_places_checkins_by_age_gender

  • page_places_checkins_by_locale

  • page_places_checkins_by_country

  • page_negative_feedback

  • page_negative_feedback_unique

  • page_negative_feedback_by_type

  • page_negative_feedback_by_type_unique

  • page_positive_feedback_by_type

  • page_positive_feedback_by_type_unique

  • page_fans_online

  • page_fans_online_per_day

  • page_fan_adds_by_paid_non_paid_unique

  • page_posts_impressions

  • page_posts_impressions_unique

  • page_posts_impressions_paid

  • page_posts_impressions_paid_unique

  • page_posts_impressions_organic

  • page_posts_impressions_organic_unique

  • page_posts_impressions_viral

  • page_posts_impressions_viral_unique

  • page_posts_impressions_frequency_distribution

  • page_actions_post_reactions_like_total

  • page_actions_post_reactions_love_total

  • page_actions_post_reactions_wow_total

  • page_actions_post_reactions_haha_total

  • page_actions_post_reactions_sorry_total

  • page_actions_post_reactions_anger_total

  • page_actions_post_reactions_total

  • page_video_views

  • page_video_views_paid

  • page_video_views_organic

  • page_video_views_by_paid_non_paid

  • page_video_views_autoplayed

  • page_video_views_click_to_play

  • page_video_views_unique

  • page_video_repeat_views

  • page_video_complete_views_30s

  • page_video_complete_views_30s_paid

  • page_video_complete_views_30s_organic

  • page_video_complete_views_30s_autoplayed

  • page_video_complete_views_30s_click_to_play

  • page_video_complete_views_30s_unique

  • page_video_complete_views_30s_repeat_views

  • page_video_views_10s

  • page_video_views_10s_paid

  • page_video_views_10s_organic

  • page_video_views_10s_autoplayed

  • page_video_views_10s_click_to_play

  • page_video_views_10s_unique

  • page_video_views_10s_repeat

  • page_video_view_time

  • page_content_activity_by_action_type_unique

  • page_content_activity_by_age_gender_unique

  • page_content_activity_by_city_unique

  • page_content_activity

  • page_content_activity_by_action_type

Post

  • post_impressions

  • post_impressions_unique

  • post_impressions_paid

  • post_impressions_paid_unique

  • post_impressions_fan

  • post_impressions_fan_unique

  • post_impressions_fan_paid

  • post_impressions_fan_paid_unique

  • post_impressions_organic

  • post_impressions_organic_unique

  • post_impressions_viral

  • post_impressions_viral_unique

  • post_impressions_by_story_type

  • post_impressions_by_story_type_unique

  • post_clicks

  • post_clicks_unique

  • post_clicks_by_type

  • post_clicks_by_type_unique

  • post_engaged_users

  • post_negative_feedback

  • post_negative_feedback_unique

  • post_negative_feedback_by_type

  • post_negative_feedback_by_type_unique

  • post_engaged_fan

  • post_reactions_like_total

  • post_reactions_love_total

  • post_reactions_wow_total

  • post_reactions_haha_total

  • post_reactions_sorry_total

  • post_reactions_anger_total

  • post_reactions_by_type_total

  • post_video_avg_time_watched

  • post_video_complete_views_30s_autoplayed

  • post_video_complete_views_30s_clicked_to_play

  • post_video_complete_views_30s_organic

  • post_video_complete_views_30s_paid

  • post_video_complete_views_30s_unique

  • post_video_complete_views_organic

  • post_video_complete_views_organic_unique

  • post_video_complete_views_paid

  • post_video_complete_views_paid_unique

  • post_video_retention_graph

  • post_video_retention_graph_clicked_to_play

  • post_video_retention_graph_autoplayed

  • post_video_views_organic

  • post_video_views_organic_unique

  • post_video_views_paid

  • post_video_views_paid_unique

  • post_video_length

  • post_video_views

  • post_video_views_unique

  • post_video_views_autoplayed

  • post_video_views_clicked_to_play

  • post_video_views_10s

  • post_video_views_10s_unique

  • post_video_views_10s_autoplayed

  • post_video_views_10s_clicked_to_play

  • post_video_views_10s_organic

  • post_video_views_10s_paid

  • post_video_views_10s_sound_on

  • post_video_views_sound_on

  • post_video_view_time

  • post_video_view_time_organic

  • post_video_view_time_by_age_bucket_and_gender

  • post_video_view_time_by_region_id

  • post_video_views_by_distribution_type

  • post_video_view_time_by_distribution_type

  • post_video_view_time_by_country_id

  • post_activity

  • post_activity_unique

  • post_activity_by_action_type

  • post_activity_by_action_type_unique

See metrics and its supported periods

Addendum

Page ID

Instead of using Page's username when creating the connector, you can use Page ID. To find the page ID, on your Facebook page, select the About menu and scroll down to the Page ID, as shown:


  • No labels