# Amazon Marketing Cloud Import Integration ## Introduction Video script script style wistia-player[media-id='mpi5lt9vz5']:not(:defined) { background: center / contain no-repeat url('https://fast.wistia.com/embed/medias/mpi5lt9vz5/swatch'); display: block; filter: blur(5px); padding-top:47.71%; } ## Overview By default, you type in a normal view. The Amazon Marketing Cloud Import Integration enables you to import the enrichment data from Amazon Marketing Cloud to the Treasure Data CDP database. ## Prerequisites - Complete [Amazon Ads API onboarding](https://advertising.amazon.com/API/docs/en-us/onboarding/overview). - Access to Amazon Marketing Cloud instance - Basic knowledge of Amazon Marketing Cloud - Basic knowledge of Treasure Data ## Static IP Address of Treasure Data Integration If your security policy requires IP whitelisting, you must add Treasure Data's IP addresses to your allowlist to ensure a successful connection. Please find the complete list of static IP addresses, organized by region, at the following link: [https://api-docs.treasuredata.com/en/overview/ip-addresses-integrations-result-workers/](https://api-docs.treasuredata.com/en/overview/ip-addresses-integrations-result-workers/) ## Import from Amazon Marketing Cloud via TD Console ## Obtain Amazon Marketing Cloud Instance ID and Account ID After logging into an Amazon Marketing Cloud instance, perform the following steps to obtain the Amazon Marketing Cloud Instance ID and Account ID. 1. Obtain the Amazon Marketing Cloud Instance ID for an instance from the Instance list. ![](/assets/amc-instance-id.abc2ce38604fb5981160a05d8e500b97dc615cb846db07a6a80964b8c22c0c9f.bd49d4d6.png) 2. View the Amazon Marketing Cloud Account ID assigned to parameter **entityId**. ![](/assets/amc-account-id.4f957be8a7083286d9c2efaaae3f84769bc09229d808004a7d75f691d1040462.bd49d4d6.png) ## 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 specify the source information. 1. Open TD Console. 2. Navigate to **Integrations Hub** >  **Catalog.** 3. Search for and select **Amazon Marketing Cloud**.![](/assets/screen-shot-2023-04-24-at-17.25.52.0744f8bd23e71ba7ca92b0cefa857d19af3e466fdc2cff6aba10511088d0c323.bd49d4d6.png) 4. Select the **Click here** link in New Authentication to connect to a new Amazon Account.![](/assets/screen-shot-2023-04-24-at-17.29.15.277937262c2647f54bf8d538db9104329274257337aac7c7a1625c23045d81f8.bd49d4d6.png) 5. You will be redirected to Amazon Marketing Cloud instance to log in using OAuth. Provide the username and password. ![](/assets/screen-shot-2023-04-24-at-17.33.04.59530de12fc559cc1e7aa5527f50209c153c9d47a35e9cc1a7021ed01b78437e.bd49d4d6.png) 6. Select **Allow** to accept consent screen. This redirects to TD console.![](/assets/screen-shot-2023-04-24-at-17.35.48.7ff015ad82656050a4ccd0b4269a763308726ae72b89bf22f3d5d90ef19cf431.bd49d4d6.png) 7. Select Amazon Marketing Cloud again, provide **AMC Instance ID,** and **AMC Account ID.** 8. Select the Amazon account for **OAuth connection**. The S3 related fields are only required for uploading audience data to Amazon Marketing Cloud. You can ignore those fields for import to Treasure Data. ![](/assets/screen-shot-2023-04-24-at-17.53.09.24886bde5787ac9b66c091f857c8280a5708095d34dd99ed13cf078c2ec36330.bd49d4d6.png) 9. Enter a name for your connection and select **Done.** ## Transfer Your Enrichment Data to Treasure Data After creating the authenticated connection, you are automatically taken to the Authentications tab. Check for the connection you created and select **New Source**. ### Create a Connection 1. Type a name for your **Source**in the Data Transfer field**.** 2. Select **Next**. ![](/assets/screen-shot-2023-04-24-at-18.12.32.780943e65505dc3aac53df05ec1c0fb391ac5bd9250b058003d0d8a9b5d04051.bd49d4d6.png) ### Identify a Source Table 1. Edit the following parameters as applicable. ![](/assets/screen-shot-2023-04-24-at-18.18.16.ef7fe388a000e573e8efe0415783233c41ac6dc555620066a251ed78d2d3af58.bd49d4d6.png) | Parameter | Description | | --- | --- | | **Query Type** | - **By Workflow** - Create or update workflow before submitting it for execution. - **On Demand**- No need to create a workflow. Uses the SQL query to submit an ad-hoc workflow. | | **Workflow Identifier** | Only required for **By Workflow** query type. | | **Query** | The SQL Query to fetch enrichment data from Amazon Marketing Cloud. For AMC Query Library for reference, see [https://advertising.amazon.com/marketing-cloud/instructional-queries](https://advertising.amazon.com/marketing-cloud/instructional-queries) | | **Workflow Parameter for SQL Query (Optional)** | The custom parameter names for SQL query. It is only required for **By Workflow** query type. | | **Workflow Parameter Values for SQL Query (Optional)** | The custom parameter values. Binds with custom parameter names when you submit workflow for execution. It is only required for **By Workflow** query type. | | **Auto Create Workflow** | Required for **By Workflow** query type. | | **Auto Update Workflow** | Required for **By Workflow** query type. | | **Time Window Type** | - **Most Recent Day** - **Most Recent Week** - **Current Month** - **Previous Month** - **Explicit Time Range** | | **Start Time** | Only required for **Explicit Time Range** query type. | | **End Time** | Only required for **Explicit Time Range** query type. | | **Schema Settings** | (Required) The schema structure for the current job. You need to edit the schema settings to add the column names and data type to match the columns used in the select statement of the query sent to AMC. Failure to do so can result in a job failing with the `Too many columns error.` | ### Define Data Settings 1. Select **Next**. The **Data Settings** page opens. 2. Optionally, edit **Data Settings** or skip this page of the dialog.![](/assets/screen-shot-2023-04-24-at-18.38.42.9a1bb59a0f4120ef7f754235fe523dc830083ba66a0f9e1a83d25e6d3de2cc06.bd49d4d6.png) ### Preview your Data Data preview is optional, and you can safely skip to the next page of the dialog if you choose to. 1. To see a[preview](https://docs.treasuredata.com/smart/project-product-documentation/previewing-your-source-data) of your data before running the import, select **Generate Preview**. 2. Select **Next**. The **Data Preview** page opens. 3. If you want to preview your data, select **Generate Preview**. 4. Verify the correct data is showing. ![](/assets/screen-shot-2023-04-24-at-18.41.29.0f67a37773fb97fae3247d62b5a1693ce36fc25225d85f7e892f886426d8671e.bd49d4d6.png) ### Define your **Data Placement** In this dialog, you can specify where your data is placed and schedule how often it runs this import. 1. Select **Next**. The **Data Placement** page opens. ![](/assets/screen-shot-2023-04-24-at-18.43.02.025ab3f419b29f37009b665f48f2bbbd7d0525cdf6b1bb42a6decc047e5f02c7.bd49d4d6.png) 2. In the **Storage** section, you can create a new or select an existing database and create a new or select an existing table where you want to place the imported data. 3. Select **Database** > **Select** **an existing** or **Create New Database**. 4. Select **Table** > **Select an existing** or **Create New Table.** 5. Choose the Append or Replace method for importing the data. 1. **Append** (default) - Data import results are appended to the table. If the table does not exist, it will be created. 2. **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. 6. Select the **Timestamp-based Partition Key** column. If you want to set a partition key seed different from 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. 7. Select the **Timezone** for your data storage. 8. Under **Schedule**, you can choose when and how often 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**.