# Amazon Marketing Cloud # Overview div iframe The **Amazon Marketing Cloud (AMC)** app integration allows advertisers using Amazon Advertising to pass CDP segments of advertiser audiences from Treasure Data (TD) in pseudonymized form. AMC combines Amazon Ads signals across advertising channels to provide custom analytics on topics such as media impact, audience segments, and customer journeys while maintaining customer privacy. ## Use Cases - **Audience overlap:** Understand the overlap between Treasure Data audiences and those engaged with their Amazon Ads campaigns. - **Audience attributes:** Assess the Amazon audience segments that contains your Treasure Data audiences. - **Off-Amazon ad impact:** Measure the impact of Amazon Ads campaigns on direct-to-customer engagements and conversions. - **Customer journey:** Evaluate customer activities across Amazon Ads channels as well as brand-owned channels such as email and website. ## Prerequisites and Limitations - Ensure that the Amazon Marketing Cloud Segment Enrichment app package is enabled in the TD Marketplace within your tenant. - You have an existing Audience and Segment within Treasure Data. - You have an existing Amazon Marketing Cloud instance. - Configured a connection between your Amazon Marketing Cloud instance and Treasure Data instance. For details, visit [Amazon DSP Data Provider Export Integration](https://docs.treasuredata.com/display/public/INT/Amazon+DSP+Data+Provider+Export+Integration). div b Info Currently, the Amazon DSP Export Integration has limitations in fully supporting the AMC app. For example, Amazon DSP does not accept hashed emails and can only accept cookies. - To use Treasure Insights Dashboards created by AMC: - TD Account must have **Treasure Insights enabled**. - TD User installing the package must have **Edit Data Models & Dashboards** permissions. - TD User installing the package must have **Workflow Edit & Run** permissions. # Setup ## 1. Connect to AMC To allow-list to your Amazon Marketing Cloud instance with Treasure Data CDP, you must contact your [Amazon Advertising Account Executive](https://advertising.amazon.com/contact-sales), or send a request to [AMC Support](mailto:amc-support@amazon.com) with your Amazon Marketing Cloud instance ID and confirm that you would like to connect to Treasure Data CDP. After this request is successfully processed, Treasure Data CDP can connect to your Amazon Marketing Cloud instance on a recurring basis. div b Info By filing this submission, you will be replacing access for any existing connections to your Amazon Marketing Cloud instance using an allow-list method. If you have questions about this, contact your TD Account Executive or Amazon Marketing Cloud Support. ## 2. Configure Treasure Data Info ![Configure TD Info](/assets/amc_td_info.7b773cb0a8389fc4dd35aa83ea5b6fef33a8688b1148a4ae38c47b888cc2a81f.b2aad8d4.png) - **API Key:** A master API key from your Treasure Data Account. - **API Endpoint:** A specific endpoint for you TD instance. For example, api.treasuredata.com, which can be obtained at [endpoints.](https://docs.treasuredata.com/display/public/PD/Sites+and+Endpoints#SitesandEndpoints-Endpoints:) - **Email to Assign Datamodels To:** Initial owner to assign data model access for Insights Models created by the app. ## 3. Configure CDP Info ![Configure CDP Info](/assets/amc_cdp_info.aadf030d6c56c3210125b637542220dbc7ac25df08f543f8ab8dc2e6f1d66549.b2aad8d4.png) - **Audience Id:** ID of the Audience. - **Segment Id:** ID of the segment within the audience. - **Cdp Endpoint:** The API endpoint of your CDP instance, which can be found here at [endpoints.](https://docs.treasuredata.com/display/public/PD/Sites+and+Endpoints#SitesandEndpoints-Endpoints:) ![Getting Audience/Segment ID](/assets/audience_segmentid_url_jpg.34dea631b3ab0a496d43e3de2a450d3b6ba592e9d1914bb549b9b5308a60abdd.b2aad8d4.jpg) ## 4. Configure AMC Info ![Configure AMC Info](/assets/amc_amc_info.351910313ec764bb8809a811a50b02c5678f552fa873a958664f22de5b645326.b2aad8d4.png) - **Amazon Marketing Cloud Instance Endpoint:** (Provided by your Amazon Marketing Cloud rep) For example: > https://xxxxxxx.execute-api.us-east-1.amazonaws.com/prod - **Data Upload AWS Account ID:** The ID of the Amazon Marketing Cloud Instance’s data upload AWS account. This can be provided by your Account Executive or Amazon Marketing Cloud support. - You may refer to the following screenshot for an example of where to find the required IDs in the Amazon Marketing Cloud UI: - The Amazon Marketing Cloud instance ID is found in the URL (highlighted). - The Amazon Marketing Cloud API endpoint and Data Upload AWS Account ID are found in the **Tasks** section. ![Getting AMC Instance Info](/assets/amc_ui.228f25983e24af0e5cba5978e0379c8cfdeb6a186a6267fe7a685791e9e2f83a.b2aad8d4.jpg) # Installed Components After the app has completed installation, the following components are installed. ## Database / Tables - **amc_upload_db.amc_log_table**: Stores event logs from interactions with Amazon Marketing Cloud API. - **amc_upload_db.amc_upload_segment_segment_id**: Segments exported to Amazon Marketing Cloud are stored in this database with the the naming convention `amc_upload_segment_segment_segment_id`. For example, segment id 12345 would be a table `amc_upload_segment_12345` in the database `amc_upload_db`. - **amc_results_db.queryname_segment_segment_id**: Results from Amazon Marketing Cloud workflows are stored in this database with the the naming convention `queryname_segment_`. For example, segment id `12345` and query / workflow name `overall_1p_user_match` would be a table `overall_1p_user_match_segment_157460` in the database `amc_upload_db`. ![workflow_results_db](/assets/workflow_results_db.b2f1a7cf202e838880124a6ebad831ca2266052ea7b47003cc856d379b16163c.b2aad8d4.jpg) - **amc_results_db.segment_matchrate**: Stores matchrate of uploaded segments. ## Queries - **queries/amc_log_table_check_logs.sql**: Check logs of app events. - **queries/check_s3_to_amc_upload_status.sql**: Check status of uploads from s3 to Amazon Marketing Cloud instance. - **queries/check_workflowExecutionId.sql**: Check status of workflow executions. ## Workflows - **amc_marketplace_app_v1.dig**: Main workflow that starts steps to get segment information and creates dataset on Amazon Marketing Cloud. - **amc_run_adhoc_query.dig**: Run adhoc query or workflow on Amazon Marketing Cloud. - **get_s3_to_amc_upload_status.dig**: Runs every 30 minutes using query `queries/check_s3_to_amc_upload_status.sql` to check status of uploads of segment information from S3 to Amazon Marketing Cloud instance. If successful upload ID is found, workflow is created and executed on Amazon Marketing Cloud and a `workflowExecutionId` is saved. - **get_workflow_status.dig**: Runs every 30 mins using `queries/check_workflowExecutionId.sql` to check status of workflow executions based on `workflowExecutionId`. If `workflowExecutionId` status is succeeded and results contain data, results will be uploaded into `amc_results_db database` with the naming convention `_segment_`. Insights Datamodel will be created with a naming convention `amc_workflowId_segment_`. For example, workflow `sbx_dsp_impressions` and segment `157460` would create datamodel `amc_sbx_dsp_impressions_segment_157460`. # Tasks #### **Create Dataset / Upload Advertiser Data (1p) to AMC** div b Info The Amazon Marketing Cloud marketplace package only uploads hashed emails for matching with Amazon Marketing Cloud. Ensure that your segments include an email field. This gets hashed by the AMC Segment Enrichment app. 1. Get the Audience and Segment ID of the segment that you would like to upload to Amazon Marketing Cloud. You can get these from viewing the segment URL in Audience Studio v5. For example: [https://console-next.treasuredata.com/app/ps/252594/e/157460/sb/da](https://console-next.treasuredata.com/app/ps/252594/e/157460/sb/da). In this instance, the Audience ID is the number after `ps` : **252594** and the segment ID is after `/e/`: **157460**. ![Getting Audience / Segment id](/assets/audience_segmentid_url_jpg.34dea631b3ab0a496d43e3de2a450d3b6ba592e9d1914bb549b9b5308a60abdd.b2aad8d4.jpg) 2. Open the `amc_marketplace_app_v1.dig` workflow. 3. Modify the `config.yml` file to insert the `audienceId` and `segmentId` of the segment you would like to upload. ![Gettinging Audience / Segmment id](/assets/config_yml_edit_jpg.240071dbfbebccab432a5c5ca167ee7f17babc461ad557c6670824dfb0f481b3.b2aad8d4.jpg) 4. Run the `amc_marketplace_app_v1.dig` workflow. 5. When the workflow ends, `uploadId` will be visible in the logs. ![workfow logs upload id](/assets/workflow_log_upload_id.588c497f75b9dac9338c4534ad2c3b7953e300c0fbf63ca4221198a475a954fd.b2aad8d4.jpg) 6. The `get_s3_to_amc_upload_status.dig` runs every 30 mins to update the status of uploads of datasets / 1p data to Amazon Marketing Cloud. 7. You can check the upload ID using the `queries/check_s3_to_amc_upload_status.sql` query to check the status of the upload. ![uploadId](/assets/upload_id_query.4d079eeefd9f04d7a3bdb40c0bbff5e381f3a11f04dfe375b65e8e558be0c29a.b2aad8d4.jpg) 8. You can confirm the data is uploaded to your Amazon Marketing Cloud instance by checking under the **Advertiser Uploaded** section for the uploaded data. ![uploadId](/assets/uploaded_1p_amc_ui.06c63441319ce66312865048abff2d435f345f3b1651509b9eea6569785c55ab.b2aad8d4.jpg) #### **Create and Run Query/Workflow on Amazon Marketing Cloud** 1. Edit the `amc_run_adhoc_query.dig` file. 2. Edit the following parameters: **dataSetId:** segment_$​{segment_id} ```JSON - **dataSetId:** segment_${segment_id} - ${segment_id} value is found in the `config.yml` file. - **queryName:** overall_1p_conversion - Select the query name for the query you would like to run from the list of queries in the `sample_queries.yml` file. - **Query:** ${overall_1p_conversion} - Enter the queryname between the ${xxxx}. - **timeWindowStart:** "2022-09-05T00:00:00" - The start time of the time window period. - **timeWindowEnd:** "2022-09-14T00:00:00" - The end time of the time window period. - **timeWindowType:** 'EXPLICIT' - Specifies the label for time window period as predefined by AMC API. For details, refer to Amazon API documentation. - **timeWindowTimeZone:** 'UTC' - The time zone. ``` 1. When you have edited the parameters as required, save and commit the `amc_run_adhoc_query.dig` file. 2. Run the `amc_run_adhoc_query.dig` file. 3. Logs for workflow run should end with the pending status of workflow and the parameters should match those entered in previous step. ![uploadId](/assets/adhoc_workflow_run.04c4453f40097e8950688337069ed9be82a4fb1da1152869253bc9601ef274be.b2aad8d4.jpg) 1. Workflow run logs will include `workflowExecutionId`. For example, `20ba9649-08fc-4daa-8dd4-bfd95b595bf3`. 2. Your Amazon Marketing Cloud workflow is now in `PENDING` status. 3. The `get_workflow_status.dig` workflow runs every 30 mins to check and update the status of `workflowExecutionId`. 4. You can run the `queries/check_workflowExecutionId.sql` query to check if the app has any pending `workflowExecutionId`. ![workflowExec_query](/assets/workflowexec_query.eb47cc857b6d32acd48e74bc9beb4102fc82f14c014f95329fd582d641e3590f.b2aad8d4.jpg) 1. When the `get_workflow_status.dig` workflow runs, it checks the status of the `workflowExecutionId`. When workflow completes, the data is uploaded into the database `amc_results_db` with table named with the convention `queryname_segment_`. ![workflow_results](/assets/workflow_results_db.b2f1a7cf202e838880124a6ebad831ca2266052ea7b47003cc856d379b16163c.b2aad8d4.jpg) 1. When workflow execution completes, a datamodel is created with a naming convention `amc_queryname_segment_`. ![insights_models_results](/assets/insights_models_results.9ebe7560225ccbad74645270ff257e5c119d4e0e6e82c868cc7c61e432298771.b2aad8d4.jpg) #### **View Amazon Marketing Cloud Workflow Results** - The results from the Amazon Marketing Cloud workflows are loaded into tables in the `amc_results_db` database with table named with the convention ``. ![workflow_results](/assets/workflow_results_db.b2f1a7cf202e838880124a6ebad831ca2266052ea7b47003cc856d379b16163c.b2aad8d4.jpg) - Datamodels from workflow results are created with the naming convention `amc_queryname_segment_`. ![insights_models_results] (./img/insights_models_results.jpg)