You can connect Facebook Lead Ads Connector with your Facebook Page or Ad Account to import Leads data into Treasure Data.

This topic includes:

Prerequisites


Obtain Get Ad ID and Form ID

Ad ID

You can retrieve the Ad ID by adding the Ad ID column to your Ads Manager screen. From the Ads Manager screen, click the (+) sign from the right-hand-side, select Customize Columns... and search for the Ad ID column as shown on the image


Form ID

You can retrieve Form ID from Publishing Tools > Lead Ads Form and hover over the existing Form as shown.


Getting the Lead Form’s Field Name

Navigate to the Lead Ads Forms.

Select Download.
Select Download new leads.

Select CSV to download the CSV file.
Open the downloaded CSV file, the field names for your form are as shown:



Use the TD Console to Create Your Connection

You complete configuration in both the Facebook interface and in Treasure Data.

Create a New Connection

When you configure a data connection, you provide authentication to access the integration. In Treasure Data, you configure the authentication and then specify the source information.

Go to Integrations Hub >  Catalog and search and select Facebook Lead Ads.

The following dialog opens.


The method you use to authenticate Treasure Data with Facebook affects the steps you take to enable the data connector to import from Facebook.

Select Click here to connect to 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.

Log into your Facebook account in the popup window:

After you grant access to Treasure Data, you are redirected back to TD Console.

Select Facebook Lead Ads again.
Select OAuth Authenticate method.
You see an OAuth connection with your account name in the dropdown list.
Select the account you want to use and then proceed to create the connection.


Select Continue
Provide Facebook Lead Ads authentication details.

Select Done.


or

You need a long-lived Access Token and optionally App Secret to authenticate using this method.
You can find more information on how to configure your connector using the Access token and App secret.
Enter the Access Token and App Secret and click Continue


Name your new Facebook Lead Ads Connection.
Select Done.



Transfer Your Facebook Leads Data to Treasure Data

After creating the authenticated connection, you are automatically taken to the Authentications tab. Look for the connection you created and click New Source.

  1. Search for the connection you created. 

  2. Select New Source. The Create Source dialog opens.

Name your Connection

  1. Type a name for your Source in the Data Transfer field.

  2. Select Next.

Source Table

    • When the checkbox Enable Guess Schema is checked, the connector downloads the first Lead Ad and performs schema guessing for field names and data type on this Ad only. If you have multiple forms and they differ in field names, data import may be missed or inconsistent. In this case, you must type all field names into the FORM FIELDS.

    • id, created_time, ad_id, ad_name, adset_id, adset_name, campaign_id, campaign_name, form_id, platform, is_organic are reserved words. Do not create a Facebook Form with these field names. Do not add these fields into the Form Fields, they are automatically added.

  1. Edit the following parameters:


Parameters:

Data Settings

Data Settings allows you to customize the data transfer. 

Do not change the Column Name. Field names in the lead form are used as column names when import. However, special characters (not alphanumeric or underscore “_”) are not supported and will be converted to underscore.

  1. Select Next. The Data Settings page opens.

  2. Optionally, edit the data settings or skip this page of the dialog.


Data Preview

Data Placement