# Integration Specifications

## **Integration Overview**&#x20;

Facebook is the largest social media platform globally, meaning it is the destination allowing advertisers to reach the largest majority of potential consumers.&#x20;

The Daasity Facebook Ads integration extracts key advertising information from the Facebook Ads platform, which includes Instagram advertising as well. Data such as spend, clicks and impressions are extracted on a daily basis and populate your data warehouse. &#x20;

{% hint style="warning" %}
**Only 37 months of history available**

Facebook exposes only the last 37 months of history in their API. We will not be able to extract data for any activity outside of that window. [(source)](https://developers.facebook.com/docs/marketing-api/reference/ad-account/insights/)
{% endhint %}

## **Integration Availability**&#x20;

This integration is available for:

* Enterprise
* Growth&#x20;

## **API  Endpoints**

The Daasity Facebook Ads extractor is built based on this [Facebook Ads Marketing Insights API Documentation](https://developers.facebook.com/docs/marketing-apis). The following endpoints are used by Daasity to replicate data from Facebook Ads.

* [Ads](https://developers.facebook.com/docs/marketing-api/campaign-structure#ads)
* [Ad Sets](https://developers.facebook.com/docs/marketing-api/campaign-structure#sets)
* [Campaigns](https://developers.facebook.com/docs/marketing-api/campaign-structure#campaigns)
* [Insights](https://developers.facebook.com/docs/marketing-api/insights/best-practices)

## **Entity Relationship Diagram (ERD)**

[Click here to view the ERD for the Daasity Facebook Ads](https://lucid.app/documents/embedded/f86e8f54-6bfa-441b-a516-66b231771f51) integration illustrating the different tables and keys to join across tables.

## Facebook Ads Schema

The Daasity Facebook Ads extractor creates these tables using the endpoints and replication methods listed.  The data is mapped from the source API endpoint to the table based on the mapping logic outlined in each table.

* [Ads](#a-ds)
* [Ad Sets](#a-d-sets)
* [Ad Spends](#a-d-spends)
* [Campaigns](#campaigns)

### **Ads**

* Endpoint: [Ads](https://developers.facebook.com/docs/marketing-api/campaign-structure#ads)
* Update Method: UPSERT
* Table Name: \[`facebook_marketing.ads`]

| JSON Element                                   | Database Column  |
| ---------------------------------------------- | ---------------- |
| id                                             | id               |
| Date queried in API                            | date             |
| name                                           | ad\_name         |
| status                                         | ad\_status       |
| Facebook Account ID                            | ad\_account\_id  |
| ID of Merchant in Daasity App                  | \_account\_id    |
| timestamp when data was extracted from Shopify | \_\_synced\_at   |

### **Ad Sets**

* Endpoint: [Ad Sets](https://developers.facebook.com/docs/marketing-api/campaign-structure#sets)
* Update Method: UPSERT
* Table Name: \[`facebook_marketing.adsets`]

| JSON Element                                   | Database Column  |
| ---------------------------------------------- | ---------------- |
| id                                             | id               |
| Date queried in API                            | date             |
| name                                           | adset\_name      |
| status                                         | adset\_status    |
| targeting::geo\_locations::countries           | target\_country  |
| targeting::publisher\_platforms                | target\_platform |
| Facebook Account ID                            | ad\_account\_id  |
| ID of Merchant in Daasity App                  | \_account\_id    |
| timestamp when data was extracted from Shopify | \_\_synced\_at   |

### **Ad Spends**&#x20;

* Endpoint: [Insights](https://developers.facebook.com/docs/marketing-api/insights/best-practices)
* Update Method: UPSERT
* Table Name: \[`facebook_marketing.ad_spends`]

| JSON Element                                   | Database Column                             |
| ---------------------------------------------- | ------------------------------------------- |
| id                                             | id                                          |
| Date queried in API                            | date                                        |
| campaign\_id                                   | campaign\_id                                |
| adset\_id                                      | adset\_id                                   |
| ad\_id                                         | ad\_id                                      |
| account\_name                                  | account\_name                               |
| spend                                          | spend                                       |
| cpc                                            | cpc                                         |
| cpm                                            | cpm                                         |
| cpp                                            | cpp                                         |
| ctr                                            | ctr                                         |
| account\_currency                              | account\_currency                           |
| date\_start                                    | date                                        |
| date\_stop                                     | date\_stop                                  |
| attribution\_setting                           | attribution\_setting                        |
| buying\_type                                   | buying\_type                                |
| conversion\_rate\_ranking                      | conversion\_rate\_ranking                   |
| engagement\_rate\_ranking                      | engagement\_rate\_ranking                   |
| objective                                      | objective                                   |
| optimization\_goal                             | optimization\_goal                          |
| quality\_ranking                               | quality\_ranking                            |
| canvas\_avg\_view\_percent                     | canvas\_avg\_view\_percent                  |
| canvas\_avg\_view\_time                        | canvas\_avg\_view\_time                     |
| cost\_per\_estimated\_ad\_recallers            | cost\_per\_estimated\_ad\_recallers         |
| cost\_per\_inline\_link\_click                 | cost\_per\_inline\_link\_click              |
| cost\_per\_inline\_post\_engagement            | cost\_per\_inline\_post\_engagement         |
| cost\_per\_unique\_click                       | cost\_per\_unique\_click                    |
| cost\_per\_unique\_inline\_link\_click         | cost\_per\_unique\_inline\_link\_click      |
| reach                                          | reach                                       |
| social\_spend                                  | social\_spend                               |
| qualifying\_question\_qualify\_answer\_rate    | qualifying\_question\_qualify\_answer\_rate |
| estimated\_ad\_recall\_rate                    | estimated\_ad\_recall\_rate                 |
| estimated\_ad\_recallers                       | estimated\_ad\_recallers                    |
| frequency                                      | frequency                                   |
| full\_view\_impressions                        | full\_view\_impressions                     |
| full\_view\_reach                              | full\_view\_reach                           |
| impressions                                    | impressions                                 |
| clicks                                         | clicks                                      |
| inline\_link\_click\_ctr                       | inline\_link\_click\_ctr                    |
| inline\_link\_clicks                           | inline\_link\_clicks                        |
| inline\_post\_engagement                       | inline\_post\_engagement                    |
| instant\_experience\_clicks\_to\_open          | instant\_experience\_clicks\_to\_open       |
| instant\_experience\_clicks\_to\_start         | instant\_experience\_clicks\_to\_start      |
| app\_custom\_event.fb\_mobile\_purchase        | mobile\_purchase\_count                     |
| onsite\_conversion.purchase                    | onsite\_purchase\_count                     |
| app\_custom\_event.fb\_mobile\_purchase        | mobile\_purchase\_value                     |
| onsite\_conversion.purchase                    | onsite\_purchase\_value                     |
| purchase\_value::adspend                       | purchase\_value                             |
| purchase\_count::adspend                       | purchase\_count                             |
| attribution\_window\["xd\_click", "xd\_view"]  | attribution\_window                         |
| Facebook Account ID                            | ad\_account\_id                             |
| ID of Merchant in Daasity App                  | \_account\_id                               |
| timestamp when data was extracted from Shopify | \_\_synced\_at                              |

### **Campaigns**&#x20;

* Endpoint: [Campaigns](https://developers.facebook.com/docs/marketing-api/campaign-structure#campaigns)
* Update Method: UPSERT
* Table Name: \[`facebook_marketing.campaigns`]

| JSON Element                                   | Database Column  |
| ---------------------------------------------- | ---------------- |
| id                                             | id               |
| Date queried in API                            | date             |
| id                                             | campaign\_id     |
| name                                           | campaign\_name   |
| status                                         | campaign\_status |
| Facebook Account ID                            | ad\_account\_id  |
| ID of Merchant in Daasity App                  | \_account\_id    |
| timestamp when data was extracted from Shopify | \_\_synced\_at   |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.daasity.com/core-concepts/data-integrations/setup-guides/digital-integrations/facebook-ads/integration-specifications.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
