To upload historical sales data, and to keep your sales data synchronized, open your Emarsys account and go to Predict > Dashboard and in the LIVE EVENTS box of the Data Collection section, click Upload data. This will take you to the Sales data page.

Here you can upload your sales data manually or through an HTTP API. Sales data uploads are incremental, meaning newer uploads add to existing sales data and do not overwrite them.

Contents

Formatting your sales data file

Sales data is expected to be a UTF-8 encoded .csv file, similar to the product catalog (if you are not sure how such file should look, a sample file can be downloaded at the bottom of this page). Each record in the file is an order line which should correspond to a single item purchased. There are a number of standard columns which are necessary for reporting, and you can also add your own custom columns.

Standard columns

Field Required Type Example Description
item Yes String BOOK0012 The unique product identifier, exactly as it appears in the item column of the product catalog.
price Yes Float 110.30 The total price of the given items (the unit price multiplied by the quantity) in the currency defined in the Account Details section of your Predict Dashboard.
order Yes String 111-U8 The unique identifier of the order (an order may contain multiple order lines).
timestamp Yes Timestamp 2016-06-06T14:02:00Z The date (and optionally the time) of the transaction (in UTC timezone). If only the date is specified (e.g. 2016-06-06), then the time is assumed to be 00:00:00.
customer Yes (one of email or customer is needed, but not both) String 12343-14B The anonymous unique identifier of the customer making the order, if your CRM uses one. This must be an external key pointing to the externalID field in your Emarsys database.
email (one of email or customer is needed, but not both) Email sportscar_fanatic@gmail.com The email address of the customer making the order, if you identify your customers by email address. Do not use this column if customer is already present. Note that due to privacy concerns, the email addresses in the uploaded historical sales data are stored encoded, so the original email address cannot be restored.
quantity Yes Float 5 Quantity (number) of purchased item(s).

Custom Columns

There may be optional custom columns in addition to the standard columns specified. Custom column names have a single character prefix which denotes their type, followed by an underscore (_) and the name of the custom column. Custom columns may be empty. However, if they contain data with the wrong type, the file will not validate.

Column Name Pattern Type Example Column Name
i_* Integer i_customer_age
f_* Float f_customer_height
t_* Timestamp t_date_of_manufacture
s_* String s_book_author

Field Types

Type Format
Integer Normal integer, no decimal or thousands separator.
Float Uses dot (.) as decimal sign, no thousands separator.
Timestamp Date of the form YYYY-MM-DD or timestamp of the form YYYY-MM-DDTHH:MM:SSZ, e.g. 2016-06-06 or 2016-06-06T14:02:00Z. If only a date is specified, the time is assumed to be 00:00:00.
String Optionally quoted string, ", To escape a quote character within a field, double it: "".
Email Email address format, eg: j@j.com

Sales Data Examples

The following example shows orders for a shoe store with two custom columns:

item,price,order,timestamp,customer,quantity,s_color,f_size,t_published
103-nike-1,24.95,112343,2016-06-06T14:02:00Z,093275854,1,blue,14.5,
105-adidas-66,99.95,112343,2016-06-06,493027334,3,black,14.5,2016-09-20T15:00:00Z
107-nike-24,50.99,66234,2016-06-06T17:00:00Z,672985375,1,pink,13.5,2016-08-01

Uploading your historical sales data

Once you are sure that your file containing your sales data has been correctly formatted as described above, you should upload it through the Predict Dashboard. It is safe to submit the same file multiple times, as this will not result in duplicate data.

You can also use the API for the initial upload (see below), but a manual upload is the preferred approach to uploading historical sales data during the onboarding process, as it allows you to validate the file and correct any errors straight away. Proceed as follows:

  • On the Sales data page, click Validate/upload file.
  • Browse for your historical data file and select it.
  • Emarsys will first validate your file and then upload it.

If there were problems validating the file, the warnings and errors will be visible immediately:

upload-sales-data-error

Keeping your sales data synchronized

Once you have made your initial upload, the Web Extend scripts will keep Emarsys synchronized with the daily activity of your webshop, but you will still need to set up a schedule for any other sales data not tracked by them. This could include returns and cancellations, as well as offline data from your physical stores. We have provided a simple HTTP API for you to do this.

The sales data should be uploaded by issuing a POST request to the following endpoint:

  • https://admin.scarabresearch.com/hapi/merchant/<merchant-id>/sales-data/api

<merchant-id> represents your 16-letter merchant ID provided by Emarsys. The request should contain an Authorization header with the following value:

  • Bearer <token>

<token> is a security token, which can be obtained by clicking on the Show API upload details button on the Sales Data page of the Predict Dashboard.

The response will have an HTTP status code of 200 if the upload was accepted (possibly with warnings), and 400 if the upload was rejected because the format or content of the sales data was invalid. The detailed error and warning messages can be seen on the Sales Data page of the Predict Dashboard. If the security token was invalid or missing, a response with 401 status will be returned.