- Create new webhooks with event
checkout update
on shopify. - Add URl handle webhooks :
your-domain/shopify_webhooks/checkout
.
Here is list of supported webhook events of shopify. And for now, we just doing with checkout webhook.
Everytime we receice webhooks request, it will be verified by method verify_request
into ShopifyWebhooksController
before continue process data. More detail about verify webhook request is here.
Note: We use signing_key
instead of share_secret_key
, we can find it by go to Settings > Notifications
and look into section Webhooks.
Segment checkout values for ecommerce stuff which referenced
https://segment.com/docs/spec/ecommerce/v2/#checkout-started
This properties we care about for now:
Property | Type | Description |
---|---|---|
order_id | string | Checkout ID |
value | number | The sum of all the prices of all the items in the checkout, taxes and discounts included. |
revenue | number | Price of the checkout before shipping and taxes |
shipping | number | Shipping cost |
tax | number | The sum of all the taxes applied to the line items in the checkout. |
discount | number | Total discounts |
currency | string | Currency code |
products | number | Total products in the checkout |
For detail properties supports by segnment [checkout creation] (https://segment.com/docs/spec/ecommerce/v2/#checkout-started)
Checkout response from checkout webhook. On List of supported webhook events and topics
, click View Response
of row Checkout
to see that.
When customer data included in checkout webhook request, we'll create new an identity based on the id
of checkout webhook and any other traits available and invite them prior to sending the segment event as an identify segment call. If there's no customer data then do nothing.
We use a hardcoded array (WHITELIST_TRAITS
) that can be used as a whitelist for shopify traits we care about.
For now, array that we use as below:
WHITELIST_TRAITS = ["email", "first_name", "last_name", "phone", "orders_count", "total_spent", "state", "verified_email"]
Trait | Type |
---|---|
string | |
first_name | string |
last_name | string |
phone | string |
orders_count | number |
total_spent | string |
state | string |
verified_email | string |