# SAP Marketing Cloud Export Integration SAP Marketing Cloud (previously Hybris Marketing) is a marketing solution that provides real-time, context-based data about individual customers and anonymous visitors by unifying user data into a centralized hub. This allows brands to deliver consistent, contextual, and relevant experiences throughout a customer journey, regardless of the marketing channel or device. Some of the features of this solution are - Data Management — provides a 360 degree view of people interacting with your brand, enabling you to target them in the right context in real-time. - Recommendations — deliver timely and highly relevant recommendations to your customers, helping you translate customer interest into conversion. - Segmentation — offers high-performing audience segmentation in real-time enabling you to personalized campaigns across multiple channels. ## What can you do with this Integration? As SAP Marketing Cloud strictly follows the Open Data Protocol (OData) principles with multiple services in their ecosystems, you can build a flexible solution which can - Export, update, and delete data to SAP Marketing Cloud products using the OData Protocol. - Support custom use cases offered by SAP Marketing Cloud [SAP Marketing Cloud - Integration APIs](https://help.sap.com/docs/SAP_MARKETING_CLOUD/0f9408e4921e4ba3bb4a7a1f75f837a7/672a497c82154a84bae6f62d63906339.md). For example, you could - Assign an Interaction Contact to a specific target group: e.g.  [SAP Marketing Cloud - Structure of OData Service API_MKT_TARGET_GROUP_SRV](https://help.sap.com/docs/SAP_MARKETING_CLOUD/0f9408e4921e4ba3bb4a7a1f75f837a7/aeff53478fc648ac817e5330e12b44d8.md). - Update or create contact relationship data: e.g.  [SAP Marketing Cloud - Structure of OData Service API_MKT_CONTACTS](https://help.sap.com/docs/SAP_MARKETING_CLOUD/0f9408e4921e4ba3bb4a7a1f75f837a7/95f2c87395bb4dda905010423029c23e.md). - Incorporate any related interaction listed in [SAP Marketing Cloud - API Hub](https://api.sap.com/package/SAPS4HANAMarketingCloud/all). ## Prerequisites - Basic Knowledge of Treasure Data™. - Basic Knowledge of SAP Marketing Cloud. - Basic Knowledge of Open Data Protocol. ## Requirements and Limitations - SAP communication user account ## 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/) ## Use the TD Console to Create a Connection In Treasure Data, you must create and configure the data connection prior to running your query. As part of the data connection, you provide authentication to access the integration. ### Create a New Authentication 1. Open **TD Console**. 2. Navigate to **Integrations Hub** > **Catalog**. 3. Search for **SAP Marketing Cloud**and select it. ![](/assets/image2022-9-27_11-11-55.1582dca8722f3a6cd89167963bf76dfe31eacd3556fcaa6cd88745a4db929c77.e4797ce9.png) 1. Select **Create Authentication**. ![](/assets/image2022-9-27_11-12-44.39756d395b1e53bfa81cf3c33f205e498b4197364d73eb3f660c958d7b1ca68d.e4797ce9.png) 1. Enter the credentials to authenticate: ![image2022-7-21_5-12-0.png](/assets/image2022-7-21_5-12-0.f1f046ae02457ce5615b5871d68336069a0651061b59733a3b3240b0f43bfe3b.e4797ce9.png) | Parameter | Description | | --- | --- | | Username | Your SAP Marketing Cloud communication username | | Password | Your SAP Marketing Cloud communication user's password | | Tenant ID | Your SAP Marketing Cloud tenant id | 1. Select **Continue**. 2. Enter a name for your connection. 3. Select **Done**. ### Define your Query 1. Navigate to **Data Workbench > Queries**. 2. Select **New Query**. 3. Enter your query. 4. Select **Run** to perform the query and to validate the result set. ![](/assets/image2022-9-27_11-21-50.123f940068e5d49a4d72e3600c65ddee494506182c6cfb9e82d94246125e3aa2.e4797ce9.png) ### Specify the Result Export Target 1. Select **Export Results**. ![](/assets/image2022-9-27_11-23-9.0ebf8dca9d15729528ea8782bc26c178939fb4e4a4e119418caf17244915781f.e4797ce9.png) 1. You can select an existing authentication or create a new authentication for the external service to be used for output. Choose one of the following: **Use Existing Integration** ![](/assets/image2021-9-7_15-28-30.d271866c7c3cea4dab234b61bea815a69b186746c80435855b4b86d1f77cc30e.e4797ce9.png) **Create a New Integration** ![](/assets/image2022-9-27_11-24-10.0a73fe3171b094e28f7eb3a3dce6feae830d49d76089768c845ec18b9ac8bded.e4797ce9.png) ![](/assets/image2022-9-27_11-26-3.73ab0f9461f044bbeaae35e0169cf83631c3d7bf8e3ead636c697ab6b325bb7e.e4797ce9.png) | Field | Description | | --- | --- | | Service Name | Target SAP Marketing Cloud service name | | Service Version | The version of service you would like to use | | Target Type | Target Type you would like to use: - Entity name - Custom path This will affect how the URL is built for the chosen action. See the [Appendix](/int/sap-marketing-cloud-export-integration#appendix) for more detail. | | Entity Name | Entity which you would like to export data to | | Custom Path URL | Custom Path URL template for resource. This is required for complicated paths which could not be handled by a standard OData entity. This option follows the format of screen-shot{{name}}—screen-shot which means that the name will be replaced by the actual data row you transferred to the integration. For example, screen-shotTargetGroups(guid'{{TargetGroupUUID}}')/TargetGroupInteractionContactsscreen-shot | | Action | The action will be applied to data- Create - Full Update - Partial Update - Delete - Upsert | | Batch Size | Number of records to egest per API call. | ### (Optional) Schedule Query Export Jobs You can use Scheduled Jobs with Result Export to periodically write the output result to a target destination that you specify. Treasure Data's scheduler feature supports periodic query execution to achieve high availability. When two specifications provide conflicting schedule specifications, the specification requesting to execute more often is followed while the other schedule specification is ignored. For example, if the cron schedule is `'0 0 1 * 1'`, then the 'day of month' specification and 'day of week' are discordant because the former specification requires it to run every first day of each month at midnight (00:00), while the latter specification requires it to run every Monday at midnight (00:00). The latter specification is followed. #### Scheduling your Job Using TD Console 1. Navigate to **Data Workbench > Queries** 2. Create a new query or select an existing query. 3. Next to **Schedule**, select None. ![](/assets/image2021-1-15_17-28-51.f1b242f6ecc7666a0097fdf37edd1682786ec11ef80eff68c66f091bc405c371.0f87d8d4.png) 4. In the drop-down, select one of the following schedule options: ![](/assets/image2021-1-15_17-29-47.45289a1c99256f125f4d887e501e204ed61f02223fde0927af5f425a89ace0c0.0f87d8d4.png) | Drop-down Value | Description | | --- | --- | | Custom cron... | Review [Custom cron... details](#custom-cron-details). | | @daily (midnight) | Run once a day at midnight (00:00 am) in the specified time zone. | | @hourly (:00) | Run every hour at 00 minutes. | | None | No schedule. | #### Custom cron... Details ![](/assets/image2021-1-15_17-30-23.0f94a8aa5f75ea03e3fec0c25b0640cd59ee48d1804a83701e5f2372deae466c.0f87d8d4.png) | **Cron Value** | **Description** | | --- | --- | | `0 * * * *` | Run once an hour. | | `0 0 * * *` | Run once a day at midnight. | | `0 0 1 * *` | Run once a month at midnight on the morning of the first day of the month. | | "" | Create a job that has no scheduled run time. | ``` * * * * * - - - - - | | | | | | | | | +----- day of week (0 - 6) (Sunday=0) | | | +---------- month (1 - 12) | | +--------------- day of month (1 - 31) | +-------------------- hour (0 - 23) +------------------------- min (0 - 59) ``` The following named entries can be used: - Day of Week: sun, mon, tue, wed, thu, fri, sat. - Month: jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec. A single space is required between each field. The values for each field can be composed of: | Field Value | Example | Example Description | | --- | --- | --- | | A single value, within the limits displayed above for each field. | | | | A wildcard `'*'` to indicate no restriction based on the field. | `'0 0 1 * *'` | Configures the schedule to run at midnight (00:00) on the first day of each month. | | A range `'2-5'`, indicating the range of accepted values for the field. | `'0 0 1-10 * *'` | Configures the schedule to run at midnight (00:00) on the first 10 days of each month. | | A list of comma-separated values `'2,3,4,5'`, indicating the list of accepted values for the field. | `0 0 1,11,21 * *'` | Configures the schedule to run at midnight (00:00) every 1st, 11th, and 21st day of each month. | | A periodicity indicator `'*/5'` to express how often based on the field's valid range of values a schedule is allowed to run. | `'30 */2 1 * *'` | Configures the schedule to run on the 1st of every month, every 2 hours starting at 00:30. `'0 0 */5 * *'` configures the schedule to run at midnight (00:00) every 5 days starting on the 5th of each month. | | A comma-separated list of any of the above except the `'*'` wildcard is also supported `'2,*/5,8-10'`. | `'0 0 5,*/10,25 * *'` | Configures the schedule to run at midnight (00:00) every 5th, 10th, 20th, and 25th day of each month. | 1. (Optional) You can delay the start time of a query by enabling the Delay execution. ### Execute the Query Save the query with a name and run, or just run the query. Upon successful completion of the query, the query result is automatically exported to the specified destination. Scheduled jobs that continuously fail due to configuration errors may be disabled on the system side after several notifications. (Optional) You can delay the start time of a query by enabling the Delay execution. ## Activate a Segment in Audience Studio You can also send segment data to the target platform by creating an activation in the Audience Studio. 1. Navigate to **Audience Studio**. 2. Select a parent segment. 3. Open the target segment, right-mouse click, and then select **Create Activation.** 4. In the **Details** panel, enter an Activation name and configure the activation according to the previous section on Configuration Parameters. 5. Customize the activation output in the **Output Mapping** panel. ![](/assets/ouput.b2c7f1d909c4f98ed10f5300df858a4b19f71a3b0834df952f5fb24018a5ea78.8ebdf569.png) - Attribute Columns - Select **Export All Columns** to export all columns without making any changes. - Select **+ Add Columns** to add specific columns for the export. The Output Column Name pre-populates with the same Source column name. You can update the Output Column Name. Continue to select **+ Add Columns**to add new columns for your activation output. - String Builder - **+ Add string** to create strings for export. Select from the following values: - String: Choose any value; use text to create a custom value. - Timestamp: The date and time of the export. - Segment Id: The segment ID number. - Segment Name: The segment name. - Audience Id: The parent segment number. 1. Set a **Schedule**. ![](/assets/snippet-output-connector-on-audience-studio-2024-08-28.a99525173709da1eb537f839019fa7876ffae95045154c8f2941b030022f792c.8ebdf569.png) - Select the values to define your schedule and optionally include email notifications. 1. Select **Create**. If you need to create an activation for a batch journey, review [Creating a Batch Journey Activation](/products/customer-data-platform/journey-orchestration/batch/creating-a-batch-journey-activation). ## (Optional) Configure Export Results in Workflow Within Treasure Data Workflow, you can specify the use of this integration to export data. Learn more at [Using Workflows to Export Data with the TD Toolbelt](https://api-docs.treasuredata.com/en/tools/cli/api/#workflow-commands). ## (Optional) Export Integration Using the CLI You can also use the TD Toolbelt for Result Export to SAP Marketing Cloud. You need to specify the information for export to SAP Marketing Cloud as screen-shot--resultscreen-shot option of screen-shottd queryscreen-shot command. For more information about screen-shottd queryscreen-shot see [Query Commands](https://api-docs.treasuredata.com/en/tools/cli/api/#query-commands). The format of the option is JSON and the general structure is as follows. ```yaml { "type": "sap_marketing_cloud", "username": "user", "password": "pass}HrNAJE", "tenant_id": "mytenant", "service_name": "API_MKT_INTERACTION_SRV", "target_type": "entity_name", "api_version": null, "entity_name": "InteractionTags", "action": "create", "batchSize": 1000 } ``` ### Parameters | Name | Description | Value | Default Value | Required | | --- | --- | --- | --- | --- | | username | Your SAP Marketing Cloud communication username | | N/A | Yes | | password | Your SAP Marketing Cloud communication user's password | | N/A | Yes | | tenant_id | Your SAP Marketing Cloud tenant id | | N/A | No | | service_name | Target SAP Marketing Cloud service name | | N/A | Yes | | api_version | The version of service you would like to use | | N/A | Yes | | target_type | Target Type you would like to use | - entity_name - custom_path | entity_name | No | | custom_path_url | Custom path URL template for resource required complicated path | For example:- TargetGroups(guid'{{TargetGroupUUID}}')/TargetGroupInteractionContacts | | Yes if **target_type** is **custom_path** | | entity_name | Entity which you would like to export data to | | N/A | Yes if **target_type** is **entity_name** | | action | The action will be applied to data | - create - update - partial_update - delete - upsert | | Yes | | batch_size | Number of records to flush per API call | | 1000 | No | | skip_invalid_records | Indicates whether invalid records should be ignored | - true - false | true | No | | retry_limit | Maximum retry times for each API call | Numeric value | 5 | No | | initial_retry_wait | Wait time for the first retry (in seconds) | Numeric value | 60 | No | | max_retry_wait | Maximum wait time for an API call before it gives up (in seconds) | Numeric value | 120 | No | | connection_timeout_secs | Max connection timeout per API call (in seconds) | Numeric value | 120 | No | | read_timeout_secs | Max read timeout per API call (in seconds) | Numeric value | 120 | No | | write_timeout_secs | Max write timeout per API call (in seconds) | Numeric value | 120 | No | ### screen-shotentity_namescreen-shot Case The following example uses **entity_name** as target_type. ```bash td query \ --result '{ "type": "sap_marketing_cloud", "username": "user", "password": "pass", "tenant_id": "mytenant", "service_name": "API_MKT_INTERACTION_SRV", "api_version": null, "entity_name": "InteractionTags", "action": "create", "batchSize": 1000 }' \ -d sample_datasets \ "SELECT * FROM interactiontags" \ -T presto ``` ### screen-shotcustom_pathscreen-shot Case The following example uses **custom_path**as target_type. ```bash td query \ --result '{ "type": "sap_marketing_cloud", "username": "user", "password": "pass", "tenant_id": "mytenant", "service_name": "API_MKT_TARGET_GROUP_SRV", "action": "create", "target_type": "custom_path", "custom_path_url": "TargetGroups(guid'\''{{TargetGroupUUID}}'\'')/TargetGroupInteractionContacts", "batch_size": 1000 }' \ -d sample_datasets \ "SELECT * FROM targetGroupinteractioncontacts" \ -T presto ``` ## Appendix ### How To Determine Entity Name Entity Namecan be retrieved in various ways. Here are two examples - Using Integration APIs Document - Using Integration APIs In this example, API_MKT_CONTACT_SRV is used as the target service. ### integrations APIs Document To retrieve data using Integration APIs Document: 1. Go to [SAP Marketing Cloud - Integration APIs](https://help.sap.com/docs/SAP_MARKETING_CLOUD/0f9408e4921e4ba3bb4a7a1f75f837a7/672a497c82154a84bae6f62d63906339.md) to find public APIs available. 2. Go to OData Service Structure for the corresponding service (e.g. [Structure of OData Service API_MKT_CONTACTS](https://help.sap.com/docs/SAP_MARKETING_CLOUD/0f9408e4921e4ba3bb4a7a1f75f837a7/95f2c87395bb4dda905010423029c23e.md)). Related information about the structures, entity sets, and supports operations is available here. ### Integrations APIs To retrieve data using **Integration APIs**: 1. Call the screen-shot$metadatascreen-shot endpoint of target service. ```bash curl --location --request GET \ 'https://{tenant}.s4hana.ondemand.com/sap/opu/odata/sap/API_MKT_CONTACT_SRV/$metadata' \ --header 'x-csrf-token: Fetch' \ --header 'Authorization: Basic {encode_base_64(username:password)}' ``` 1. From the response documents, find the screen-shotEntityContainer Name="{TARGET_SERVICE}_Entities"screen-shot . In this example, this will be screen-shotEntityContainer Name="API_MKT_CONTACT_SRV_Entities".screen-shot ```xml ``` 2. Choose the screen-shotEntitySetscreen-shot you would like to ingest. 3. Copy the text inside the screen-shotName=screen-shot quotations marks. This name will be used in the GUI: e.g. **Contacts**, **MarketingAreas**, **MarketingLocations**, **ContactOriginData**, etc. ### Target Type Target types affect how the URL is built for chosen action. There are two options for Target Type: - Entity name - Custom path. Using the entity name option, the prefix of the URL will be built based on screen-shottenant_idscreen-shot, screen-shotservice_namescreen-shot, and screen-shotentity_namescreen-shot with following template: ``` https://{{tenant_id}}.s4hana.ondemand.com/sap/opu/odata/sap/{{service_name}}/{{entity_name}} ``` Using the custom path option, the prefix of the URL will be built based on screen-shottenant_idscreen-shot, screen-shotservice_namescreen-shot, and screen-shotcustom_path_urlscreen-shot, and exported data*.* The custom path is built by expanding tags in a screen-shotcustom_path_urlscreen-shot using values provided from the exported data. Then, it is combined with the common prefix. ``` https://{{tenant_id}}.s4hana.ondemand.com/sap/opu/odata/sap/{{service_name}}/{{custom path} ``` For example, with the following custom_path configuration: ``` target_type: custom_path tenant_id: my_tenant service_name: API_MKT_CONTACT_SRV custom_path_url: TargetGroups(guid'{{TargetGroupUUID}}')/TargetGroupInteractionContacts ``` And using the following exported data: ``` InteractionContactUUID,TargetGroupUUID 00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000001 ``` The URL endpoint for the custom path would be: ``` https://my_tenant.s4hana.ondemand.com/sap/opu/odata/sap/API_MKT_CONTACT_SRV/TargetGroups(guid'00000000-0000-0000-0000-000000000001')/TargetGroupInteractionContacts ```