Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: first pass

...

  • Basic knowledge of Treasure Data, including the TD Toolbelt

  • A Facebook Page/Ad account with Leads retrieval permission

  • Authorized Treasure Data account access


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 Ad ID column as shown on the image

Image Added


Form ID

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


Image Added

Getting the Lead Form’s Field Name

Numbered Headings
start-numbering-with1
start-numbering-ath5
Go to your Lead Ads Forms 

Image Added

Click the Download button and select Download new leads

Image Added

Choose CSV to download the CSV file. Image Added
Open the downloaded CSV file, the field names for your form as shown.

Image Added



Use the TD Console to Create Your 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.

Numbered Headings
start-numbering-with1
start-numbering-ath5
Go to Integrations Hub >  Catalog and search and select Facebook Lead Ads.

Image Removed

Image Added. The following dialog opens.

Image Modified


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

...

Using OAuth

...

Expand
titleOauth...
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.

Image Modified

Log into your Facebook account in the popup window:

Image Modified

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.

Image Modified

...


Select Continue
Provide Facebook Lead Ads authentication details.

...

Image Added

Select Done.


or

...

Expand
title

...

Access Token...

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

Image Modified

...


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.

Connection

...

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

...

  1. field.

  2. Select Next.

Source Table

...

Info
    • 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 are 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:

    • Ad Account ID: (Optional) Your Facebook ad account id
    • AD ID/Form ID: (Required if Ad Account ID is not set) Leads data can be imported by Ad Id or Form ID.

  • See the Appendix for details how to get Ad ID and Form ID
    • Created Time From: (Optional) Import Leads data submitted

  • since
    • from this time until the current time. The field accepts ISO 8601 date-time format.

  • E.g.
    • For example, 2020-01-01T00:00:00+0700

    • Incremental: Only import new data since the last run.

    • Enable Guess Schema: Use this feature to let the connector guess the form fields automatically, or you can
  • manually enter
    • type the form fields by
  • unchecking
    • clearing this
  • checkbox
    • and
  • fill
    • filling in the Field Name and Data Type in the FORM FIELDS.
      • Field Name: The Lead Form field name.
  • See the Appendix for how to get the Lead Form’s Field Name
      •  
      • Data Type: The data type of this field.

      • Timestamp format: You provide the timestamp format if the field is a timestamp field e.g. %Y-%m-%dT%H:%M:%S%z

Data Settings

Data Settings allows you to customize the data transfer. 

Info
  • When the checkbox Enable Guess Schema is checked, the connector will download the first Lead Ad and perform schema guessing for field names and data type on this Ad only. If you have multiple forms and they are different in field names, data import may be missed or inconsistent. In this case, you must manually enter 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 preserved names and you must not create a Facebook Form with these fields name and you don’t need to add these field into the Form Fields, it is automatically added

Data Settings

...

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.

  • Skip invalid record(s): If selected, skips invalid Leads data and continues to import others. If not selected, jobs fail when invalid data is encountered.

  • Schema Settings: You can change the Data Type or Timestamp format column column if you find the data type or timestamp format is invalid for that column

...

  • .


Data Preview

Excerpt Include
Data Preview
Data Preview
nopaneltrue

...

Excerpt Include
Data Placement
Data Placement
nopaneltrue

How to Get Ad ID and Form ID

Ad ID

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

Image Removed

Form ID

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

Image Removed

Getting the Lead Form’s Field Name

...

start-numbering-with1
start-numbering-ath5
Go to your Lead Ads Forms 

Image Removed

Click the Download button and select Download new leads

Image Removed

Choose CSV to download the CSV file. Image Removed
Open the downloaded CSV file, the field names for your form as shown.

...