AfterShip Tracking Common Scenario
One of the most common usage of the Commerce API is to import shipments to AfterShip Tracking, in order to send out the order/shipment update notification. Also the shopper can also visit AfterShip branded tracking page to view the order/shipment latest status or registering email/sms updates.
This document will describe several common usage scenarios for AfterShip Tracking, provided for your reference.
Please be sure to reach out to the AfterShip support team or contact your customer success manager to activate your store ID for AfterShip Tracking usage.
1. Import the Order
The first step is to import your order into AfterShip system, you can import the your order with order
endpoints. Once you have successfully imported orders, you can view the shipments under the AfterShip Tracking admin portal.
All sample requests in this tutorial will include only the minimum required fields necessary to utilize the desired feature. For detailed definitions of other fields, please visit Order API Reference.
Common Required Fields
Field | Description | Sample |
---|---|---|
source_id | The unique identifier of the order. For most of the case it should be the same as the order ID of your system. | CM1011 |
number | The order name | CM1011 |
currency | The curreny of the order | USD |
status | The status of the order | open |
order_total | The total price of the order | 9.5 |
items | Items of order | - |
items.*.source_id | A unique identifier for the line item in your system | 9716591689898 |
items.*.title | The title of the product variant | Mobile Phone Case |
itmes.*.quantity | The number of items that have been purchased | 1 |
source_created_at | The date and time (ISO 8601 format) when an order was created | 2023-02-16T01:00:10Z |
source_updated_at | The date and time (ISO 8601 format) when an order was updated. | 2023-02-16T01:00:10Z |
shipments | Order shipments | - |
shipments.*.source_id | A unique identifier for the shipment in your system. | 321324145553321 |
shipments.*.tracking_number | Tracking number. | 32332131122 |
shipments.*.slug | Unique code of the courier. Get couriers here: https://www.aftership.com/couriers. | fedex |
Sample JSON
preparing...
2. Prepare the Request Data
Depending on the intended usage, you will need to include various auxiliary data along with the common fields outlined in the previous section.
2.1 Sending Email Notifications
AfterShip Tracking allows you to send email notifications for different delivery statuses. With swift email notifications, you can keep your customers updated about their order status.
Specific Required Fields
Field | Description | Sample |
---|---|---|
customer | Customer information object | - |
customer.emails | The customer's email array | ["[email protected]"] |
Sample Request
2.2 Sending SMS Notifications
To use the sms notification feature, please add the valid customer phone numbers (customer.phones) to the order payload.
Specific Required Fields
Field | Description | Sample |
---|---|---|
customer | Customer information object | - |
customer.phones | The customer's phone number array | ["+12025553750"] |
Sample Request
2.3 Notification workflow based on the order status
If you want to configure an notification workflow based on the status of an order, you will also have to provide the fulfillment_status.
Specific Required Fields
Field | Description | Sample |
---|---|---|
customer | Customer information object | - |
customer.emails | The customer's email array | ["[email protected]"] |
customer.phones | The customer's phone array | ["+12025553750"] |
fulfillment_status | The status of fulfillment associated with the order | unfulfilled |
Sample Request
2.4 Notification workflow using workflow trigger filters
If you want to set up an email/sms workflow using workflow trigger filters, you can use the corresponding fields in the following reference table:
Field | Trigger Filter Name | Example |
---|---|---|
number | Order number | CM1011 |
status | Order status | CM1011 |
items[*].product_categories | Product type | ["makeup"] |
shipping_address.country_region | Destination country/region | USA |
shipments[*].slug | Slug | "fedex" |
shipments[*].custom_fields | Custom fields | {"customer_tag": "testing"} |
source | Please select automizely-private | - |
Sample Request
2.5 Custom EDD
The custom estimated delivery date (Custom EDD) is used in cases where you already have a mechanism to calculate the estimated delivery date based on the shipping type, carrier, and destination. Please refer to here for more detail about Custom EDD feature.
The general formula for calculating the custom EDD for the selected industry type is as follows:
Order date
+ Order cutoff & processing time
+ Transit time
Please refer to the table below for instructions on how to input the mentioned variables into the AfterShip system:
Variable | Description |
---|---|
Order date | The order creation time should be passed via the "source_created_at" field in the order payload. |
Order cutoff & processing time | The processing time for an order is configured on the Tracking's admin page. |
Transit time | The estimated shipping time is configured on the Tracking's admin page. |
2.6 Segmentation
Please refer to here for more detail about Segmentation feature.
To use the Segmentation feature, you should send the required order information to AfterShip via Order API according to the referencetable below:
Commerce API Field Name | Segmentation Condition Field Name |
---|---|
order_total | Order -> Total billing amount |
tags | Order -> Order tag |
number | Order -> Order number |
items[*].sku | Product -> Product SKU |
items[*].product_categories | Product -> Product type |
items[*].product_tags | Product -> Product tag |
shipments[*].slug | Shipment -> Carrier |
name | Shipment -> Shipment title |
shipping_address.country_region | Shipment -> Destination country/region |
shipping_address.state | Shipment -> Destination state |
shipping_address.postal_code | Shipment -> Destination postal code |
shipments[*].custom_fields | Custom field |
2.7 Product Recommendation
The AfterShip product recommendation feature enables you to display the most suitable products to your shoppers based on various behaviors and criteria. To utilize this feature, you must import order and product resources into AfterShip.
Importing Products
Importing Orders
2.8 Product documents
If you want to use the Product documents feature, please import order and product resources according to the following examples:
Key field | description |
---|---|
order.shipments[*].custom_fields.package_count | The total number of packages to be unpacked for this shipment should be entered. For example, if the order requires 2 packages to be unpacked for shipment, please enter 2. Tracking will use this information to determine the last package of the shipment. Once Tracking confirms that the last package has been delivered, the product documents will be sent. |
2.9 Notifications - Flow
To create a custom flow and utilize flow filters related to shopping behavior, you can import order, and product data following the examples provided below:
Key field | description |
---|---|
order.customer.source_id | A unique identifier for the customer. The ID will be used to calculate values related to SHOPPING BEHAVIOR. |
order.financial_status | The financial_status should not be unpaid. Only when financial_status is not equal to 'unpaid', the order will be used to calculate values related to SHOPPING BEHAVIOR. |
order.source_created_at | The creation time of the order used to calculate the number of orders within the relevant time period. Related SHOPPING BEHAVIOR:First order date ,Last order date ,Number of recent orders . |
order.order_total | Related SHOPPING BEHAVIOR:Total spent ,Avg. order value . |
order.items[x].source_product_id | Related SHOPPING BEHAVIOR:Purchased products . |
order.items[x].source_variant_id | Related SHOPPING BEHAVIOR:Purchased products . |