If you are using the Smart Insight customer intelligence module, you can easily integrate your Salesforce shop and export your sales data to Emarsys to help build relevant customer lifecycle segments. You should do this right after you have finished configuring your basic custom preferences.
Preparing your database fields for export
In the Salesforce SmartInsight Configuration page you can add (and remove) the Salesforce fields that you want to include in your daily export, and map them to Emarsys fields. These fields will be prepared in a .csv file that will be placed on the storage location that you define below. The export file structure is as follows:
- Name: sales_items_<YYYYMMDDHHiiss>_<shopinfo>.csv
- Encoding: UTF-8
- Columns separator: Comma ( , )
To select and map your fields, open the Business Manager and go to Merchant Tools > Emarsys Integration > SmartInsight Configuration.
The following fields are mandatory for the .csv file:
- Order – The order number.
- Date – The date of the order (YYYY-MM-DD).
- Customer – The unique customer ID (this ID must be available in Emarsys as well).
- Item – The product ID of the sold item (this ID must match the one in the products .csv as well).
- Quantity – The quantity of the ordered item.
c_sales_amount – The price of the sold items (this value must be negative if an order was cancelled).
For Smart Insight, a daily .csv feed with the orders from the last 24 hours must be delivered to a server where Emarsys can fetch it.
In addition to these you can add custom order attributes. Click Add fields and select the attribute you want to add from the Available elements list. Define the column name (which must be the same as the Emarsys field name to which it is mapped) for that attribute, then repeat for all the additional fields you want. Remember that the column name for these fields must begin with c_.
Note: Only custom attributes that you have defined in the emarsysSmartInsightAvailableElements site preference are listed here (see below for details).
Configuring the daily export
Now that you have prepared your database fields, you can configure the export. Proceed as follows:
In the Custom Site Preferences, select EmarsysSmartInsight.
This will open the EmarsysSmartInsight Configuration.
Make the following settings:
- Enable SmartInsight – Enable or disable the Smart Insight order export.
- SmartInsight destination folder – Set the destination folder for the order export feed on the Smart Insight SFTP server.
- Enable SmartInsight TimeFrame – Enable or disable the Smart Insight Timeframe. If this box is unchecked, it means that the timeframe isn’t taken into consideration and the export will contain all orders completed in the last 24 hours.
- TimeFrame Start – The setup timeframe start date for the Emarsys historical export job.
- TimeFrame End – The setup timeframe end date for the Emarsys historical export job.
- SmartInsight Available Elements – A list of available attributes for the Smart Insight order export .csv. These are matched to the fields in Emarsys and must also conform to the syntax requirements of the Predict product catalog. See Custom attributes for export below for more details.
- SFTP username – The Emarsys SFTP server username for Smart Insight.
- SFTP host – The Emarsys SFTP hostname for Smart Insight.
- SFTP password – The Emarsys SFTP password for Smart Insight.
Setting up the export job
Now you must set up the Salesforce job that will collect the order data, compile the .csv file and place it on the export SFTP server.
In the Business Manager, go to Administration > Operations > Workflow schedules, select the Emarsys Export Orders job and click Edit.
Here you configure the Emarsys Export Order job:
- Enabled – This enables or disables the job on your Salesforce site.
- Name – The name of the job.
- Description – Description of this job.
- Runtime – You define the frequency of the job.
When you have defined the frequency of the job, click Run. Then go to the SFTP server and check that the folder you created in the SmartInsight Configuration page is there and contains be new export file with orders.
The file name should be in the correct format: sales_items_YYYYMMDD_HHiiss_shopinfo.csv
Open the new export file and check that the columns match the mappings for the attributes you selected in the SmartInsight Configuration page:
Running the Smart Insight Workflow Schedule
The EmarsysExportOrders workflow schedule exports order data into a .csv file via the Integration Framework. Every field in the .csv file will be mapped to a corresponding field in Emarsys.
To run the workflow, log in to the Business Manager and go to Administration > Operations > Workflow schedules and check if the EmarsysExportOrders workflow is scheduled daily. Then run the workflow.
Custom attributes for export
Emarsys Smart Insight attributes are configurable under the emarsysSmartInsightAvailableElements site preference (Merchant Tools > Site Preferences > Custom Site Preference Groups > Emarsys SmartInsight Configuration).
In addition to the mandatory attributes, you can add any Salesforce product custom attributes such as custom.product.color. The column names for these additional columns must start with c_. For example, to add the attribute color to the sales items the column name could be: c_color.
The following kinds of custom attributes are possible:
Billing address – The available element should start with billingAddress, and it should contain real attributes. In this way, we get the required values from the billingAddress object.
Shipping address – The available element should start with shippingAddress, and it should contain real attributes. In this way, we get required values from the order.shipments.shippingAddress object.
General order attributes – The available element should start with order, and it should contain real attributes. In this way we get needed values from the order object.
- Delivery method – This is a separate case for the deliveryMethod.display element only. It reads the shipping method name and description from the order.shipments.shippingMethod object.
- Payment method – This is a separate case for the paymentMethod.display element only. It reads the first payment method from the order object.
- Order rebate – This is a separate case for the orderRebate element only.
- Shipping costs – This is a separate case for the shippingCosts.display element only. Tt reads the shipping total price from the order.shipments object.
- customerNo – This is a separate case for the customer No.
- Custom attributes – There are 3 types of custom attributes available for output: custom.order, custom.product and custom.lineItem. These represent the Order, Product and ProductLineItem/GiftCertificateLineItem object attributes respectively. Please see https://documentation.demandware.com/DOC2/index.jsp to see the full list of available attributes for these objects.
- Specific custom attributes – The tracking number, shipment company, date of arrival and tracking link should have the following element definitions: custom.shipmentTrackingNumber, custom.shippingCompany, custom.arrivalDate, custom.trackingLink. The available element should begin with custom. It reads the custom attributes values from the order.shipments object.