You can use the Facebook Offline Conversions BETA to send job results (in the form of offline event data) from Treasure Data directly to Facebook to measure how much your Facebook ads lead to real-world outcomes, such as purchases in your stores, phone orders, bookings, and more.

This data connector is in Beta. For more information, contact support@treasuredata.com.

This topic contains:

Prerequisites

  • Basic Knowledge of Treasure Data.

  • Basic knowledge of Facebook Offline Conversions and Facebook Offline Event

  • To upload event data, you need access to one of the following on Facebook:

    • Business Manager admin

    • Admin system user who created the offline event set

    • Admin on the ad_account connected to the offline event set 

Use the TD Console to Create Your Connection

Create a New Connection

In Treasure Data, you must create and configure the data connection to be used during export prior to running your query. As part of the data connection, you provide authentication to access the integration.

  1. Open TD Console.

  2. Navigate to Integrations HubCatalog.

  3. Search for and select Facebook Offline Conversions.

  4. After, the following dialog opens, choose your type of Authentication Method, further described in the following section.


  5. Enter a name for your connection.

  6. Select Done.

Authenticating your Connection

The method you use to authenticate Treasure Data with Facebook affects the steps you take to enable the data connector to access Facebook. You can choose to authenticate in the following ways:

  • Access Token

  • OAuth

Using Access Token to Authenticate

You need an access token and client secret to authenticate using Access Token. A long-lived user access token or system user access token is recommended. You may need to create a long-lived access token or a system access token.

You need to assign ads_management permission to your access_token.

Using OAuth to Authenticate

Using OAuth is the most common authentication method. Authentication requires that you manually connect your Treasure Data account to your Facebook Ads account.
To authenticate, complete the following procedure:

  1. Select on Click here to connect a new account. You are redirected to Facebook to log in if you haven't login yet, or the consent page to grant access to Treasure Data.


  2. Log into your Facebook account in the popup window and grant access to the Treasure Data app. You will be redirected back to TD Console.


  3. Repeat the first step (Create a new connection) and choose your new OAuth connection.

  4. Name your new Facebook Offline Conversions connection.

  5. Select Done.

Configure Export Results in Your Data Connection

In this step, you create or reuse a query. In the query, you configure the data connection.

You need to define the column mapping in the query. The columns in the query represent Offline Event data to be uploaded into Facebook.

Additionally, the match_keys column and its data are hashed/normalized before being sent to Facebook. Learn more about hashing and normalization requirements. You need at least one match_keys column to configure export results.

Column name

Data type

Match Key

Required

Multiple

Example

email

string

Yes

No

Yes

foo@fb.com

phone

string

Yes

No

Yes

1-202-555-0192

gen

string

Yes

No

No

M

doby

string

Yes

No

No 

1990

dobm

string

Yes

No

No

10

dobd

string

Yes

No

No

20

ln

string

Yes

No

No

Bar

fn

string

Yes

No

No

Foo

fi

string

Yes

No

No

L

ct

string

Yes

No

No

Long Beach

st

string

Yes

No

No

California

zip

string

Yes

No

No

90899

country

string

Yes

No

No

US

madid

string

Yes

No

No

aece52e7-03ee-455a-b3c4-e57283

extern_id

string

Yes

No

No


lead_id

string

Yes

No

No

12399829922

event_time

long

No

Yes

No

1598531676

event_name

string

No

Yes

No

Purchase

currency

string

No

Yes

No

USD

value

double

No

Yes

No

100.00

content_type

string

No

No

No


contents

json string

No

No

Yes

{"id": "b20", "quantity": 100}

custom_data

json string

No

No

No 

{"a":12, "b":"c"}

order_id

string

No

No

No

OD123122

item_number

string

No

No

No


To include Data Processing Options specifying these columns mapping in your query

Column name

Data Type

Required

Multiple

Example

data_processing_options

string

No

No

“LDU“

data_processing_options_country

long

No

No

1

data_processing_options_state

long

No

No

1000

To query multiple values with the same name, you specify the name multiple times in the query. For example:

SELECT home_email as email, work_email as email, first_name as fn, last_name as ln
FROM table my_table

Configure the Connection by Specifying the Parameters

  1. Open the TD Console.

  2. Navigate to Data Workbench > Queries.

  3. Select the query that you plan to use to export data.

  4. Select Export Results located at top of your query editor. 
    The Choose Integration dialog opens.
    You have two options when selecting a connection to use to export the results, using an existing connection or by first creating a new one.

Use an Existing Connection

  1. Type the connection name in the search box to filter.

  2. Select your connection.

  3. Set the following parameters:

Parameter

Description

Offline Event Set ID (required)

Facebook offline event set ID. See Appendix where to find Offline Event Set ID.

Upload Tag (required)

Use to track your event uploads

Namespace ID (optional)

Scope used to resolve extern_id or tpid. Can be another data set or data partner ID.

Example: 12345

Match Keys (required)

The identifying information used to match people on Facebook. The values is a comma-separated string.

Example: email,phone,fn,ln,st,country…

Skip Invalid Data (optional)

Use to terminate job (without revert) when invalid records are encountered. For example: a record is missing the required columns e.g. event_name, event_time...

Here is a sample configuration: 

Example of a Query to Populate Offline Events Data

From Treasure Data, run the following query with export results into a connection for Facebook Offline Conversions:

  • Regular SELECT query from a table

SELECT 
  an_email_column       AS EMAIL,
  a_phone_column        AS PHONE,
  an_event_time_column  AS EVENT_TIME,
  an_event_name_column  AS EVENT_NAME,
  a_double_column       AS VALUE,
  a_currency_column     AS CURRENCY
FROM your_table;
  • Query multiple email, phone columns for multiple values

SELECT
  'elizabetho@fb.com' as email,
  'olsene@fb.com'     as email,
  '1-(650)-561-5622'  as phone,
  '1-(650)-782-5622'  as phone,
  'Elizabeth'         as fn,
  'Olsen'             as ln,
  '94046'             as zip,
  'Menlo Park'        as st,
  'US'                as country,
  '1896'              as doby,
  'Purchase'          as event_name,
  1598531676          as event_time,
  150.01              as value,
  'USD'               as currency
  • Query with multiple contents

SELECT
  'elizabetho@fb.com' as email,
  'Purchase'          as event_name,
  1598531676          as event_time,
  150.01              as value,
  'USD'               as currency
  '{"id": "b20", "quantity": 100}' as contents
  '{"id": "b21", "quantity": 200}' as contents
  • Query custom_data column

SELECT
  'elizabetho@fb.com' as email,
  'Purchase'          as event_name,
  1598531676          as event_time,
  150.01              as value,
  'USD'               as currency
  '{"a":12, "b":"c"}' as custom_data

Optionally Use Scheduled Jobs for Export

You can use Scheduled Jobs with Result Export, to periodically write the output result to a target destination that you specify.

Optionally Configure Export Results in Workflow

Within Treasure Workflow, you can specify the use of this data connector to export data.

timezone: UTC

_export:
  td:
    database: sample_datasets

+td-result-into-target:
  td>: queries/sample.sql
  result_connection: facebook_offline_conversions
  result_settings:
    event_set_id: 361738844830373
    upload_tag: purcharse_event_upload
    match_keys: email,phone,ln,fn

Learn about Using Workflows to Export Data with the TD Toolbelt for more information on using data connectors in a workflow to export data.

Offline Event Set ID

  1. Open the Business Manager dashboard, select Event Manager.

  2. Select an Event Set.

  3. Select the Settings and the Offline event set ID is displayed.


  • No labels