Shopify
Elton lấy dữ liệu cửa hàng Shopify qua Shopify GraphQL Admin API (phiên bản 2026-07): đơn hàng, sản phẩm, khách hàng, tồn kho, thanh toán Shopify Payments và các dữ liệu liên quan. Elton xác thực bằng một app bạn tạo cho store (Dev Dashboard app hoặc custom app cũ), và chỉ gửi truy vấn đọc (query), không tạo hay sửa dữ liệu trên Shopify.
1. Tạo app trên Shopify
Elton cần một app được cài trên store của bạn. Có hai loại app, tương ứng với ô App type khi tạo data source ở Elton:
| App type ở Elton | Dùng khi | Thông tin cần lấy |
|---|---|---|
| Dev Dashboard app (mặc định khi tạo mới) | App mới tạo trong Shopify Dev Dashboard | Client ID và Client Secret (cách A) |
| Custom app (legacy) | Store đã có sẵn custom app tạo trong Shopify Admin | API Password, tức Admin API access token (cách B) |
Từ ngày 1/1/2026, Shopify không cho tạo mới legacy custom app. Nếu store chưa có custom app, hãy dùng Dev Dashboard app. Thông báo của Shopify: Legacy custom apps can't be created after January 1, 2026.
Dù dùng loại nào, app phải có đủ quyền đọc (Admin API access scopes) cho các loại dữ liệu bạn định lấy (xem Quyền cần cấp cho app).
Cách A: Dev Dashboard app (Client ID và Client Secret)
- Vào Shopify Dev Dashboard, mở tab Apps và bấm Create app. Đặt tên app, ví dụ
Elton Data Integration. - Ở phần cấu hình quyền Admin API scopes của app, chọn các scope bắt đầu bằng
read_theo bảng quyền, rồi lưu lại. - Cài app vào store cần lấy dữ liệu (chọn Install và chọn đúng store).
- Mở phần thông tin xác thực (credentials) của app, sao chép Client ID và Client Secret.
Elton dùng Client ID và Client Secret để xin access token từ store (client credentials grant). Token này có hạn 24 giờ; khi token hết hạn giữa lần chạy, Elton tự xin token mới. Bạn không cần bấm trao quyền (Authorize) ở Elton.
Shopify chỉ cấp token theo cách này khi store thuộc cùng tổ chức (organization) Shopify với app trong Dev Dashboard. Nếu store thuộc tổ chức khác, lần chạy lỗi shop_not_permitted (xem Lỗi thường gặp). Khi đó hãy tạo app trong Dev Dashboard của tổ chức sở hữu store.
Khi đổi (rotate) Client Secret trên Shopify, hãy cập nhật Client Secret mới ở data source trên Elton, nếu không các lần chạy sẽ lỗi.
Cách B: Custom app (legacy) và API Password
Chỉ dùng cho store đã có sẵn custom app tạo trong Shopify Admin trước ngày 1/1/2026. Vào Shopify Admin:
- Vào Settings.

- Vào Apps and sales channels, bấm Develop apps.

- Bấm Allow custom app development, rồi bấm Allow custom app development một lần nữa để xác nhận.

- Bấm Create an app và đặt tên app, ví dụ
Elton Data Integration.

- Vào Configure Admin API scopes, chọn các scope bắt đầu bằng
read_theo bảng quyền, rồi bấm Save.

- Bấm Install app.

- Bấm Reveal token once để hiện Admin API access token, rồi sao chép. Shopify chỉ hiện token này một lần. Token này là API Password khi tạo data source ở Elton.

Token của custom app không tự làm mới được. Khi đổi token trên Shopify, hãy cập nhật API Password mới ở data source trên Elton.
Quyền cần cấp cho app (Admin API scopes)
Chỉ cần quyền đọc. Cấp quyền cho các loại dữ liệu bạn định chọn khi tạo connection:
| Loại dữ liệu ở Elton | Scope cần có |
|---|---|
| Order, Order Agreement, Abandoned Checkout, Customer Journey Summary | read_orders |
| Customer | read_customers |
| Product, Collection | read_products |
| Inventory | read_inventory |
| Location | read_locations |
| Payment Dispute | read_shopify_payments_disputes |
| Payment Account Balance Transaction | read_shopify_payments_accounts và read_shopify_payments_payouts |
| Staff Members | read_users |
| Fulfillment Order | Quyền đọc fulfillment order của Shopify |
Thiếu scope thì lần chạy lỗi Shopify denied access to field ... (needs '<scope>'), kèm tên scope còn thiếu. Thêm scope cho app xong, hãy cài lại (hoặc duyệt lại) app trên store để quyền mới có hiệu lực. Danh sách scope của Shopify: Access scopes.
2. Tạo data source
- Vào Data Sources → Create data source, ở ô Type chọn Shopify.
- Điền form:
| Trường | Giá trị |
|---|---|
| Name | Tên hiển thị của source, ví dụ Elton Shopify |
| Description | Mô tả, không bắt buộc |
| Shop name | Bắt buộc. Tên store lấy từ URL khi đăng nhập Shopify Admin: với https://admin.shopify.com/store/elton-data-test thì Shop name là elton-data-test. Elton gọi API tại https://<Shop name>.myshopify.com. Shop name cũng là hậu tố tên bảng ở destination (xem mục 4) |
| App type | Dev Dashboard app (mặc định khi tạo mới) hoặc Custom app (legacy). Xem bước 1 |
| Client ID | Chỉ hiện khi App type là Dev Dashboard app. Client ID của app (cách A) |
| Client Secret | Chỉ hiện khi App type là Dev Dashboard app. Client Secret của app |
| API Password | Chỉ hiện khi App type là Custom app (legacy). Admin API access token của custom app (cách B) |
| Shopify plan | Gói Shopify của store: Basic (mặc định), Shopify, Advanced hoặc Plus. Không làm thay đổi dữ liệu Elton lấy; Elton dùng gói này để chọn tốc độ gọi API phù hợp với giới hạn của Shopify (gói cao hơn được gọi nhanh hơn) |
| App has read_users permission | Bật khi app có scope read_users. Khi bật, bảng đơn hàng có thêm nhân viên tạo đơn (cột staff_member, và staff_member trong từng sản phẩm của line_items). Mặc định tắt |
- Bấm Create data source.
Data source có App type để trống (tạo trước khi có lựa chọn này) được hiểu là Custom app (legacy).
Khi sửa data source, ô Client Secret hoặc API Password hiện dạng **********. Để nguyên thì Elton dùng giá trị đã lưu.
Tên bảng ở destination lấy theo Shop name. Đổi Shop name của một source đã chạy thì các lần chạy sau ghi vào bảng mới; dữ liệu đã lấy vẫn nằm ở bảng cũ.
3. Tạo connection
Khi tạo connection với source là Shopify, phần Source config có:
- Select 1 or many type of data: chọn một hoặc nhiều loại: Order, Order Agreement, Fulfillment Order, Product, Collection, Customer, Location, Inventory, Payment Dispute, Payment Account Balance Transaction, Customer Journey Summary, Abandoned Checkout, Staff Members (Required read_users permission). Mỗi loại là một bảng ở destination (xem mục 4).
- Inventory granularity (chỉ hiện khi chọn Inventory): Latest (mặc định) giữ một dòng tồn kho mới nhất cho mỗi mặt hàng; Day giữ một dòng cho mỗi mặt hàng mỗi ngày (xem Inventory).
- First run loads from (bắt buộc): ngày bắt đầu lấy dữ liệu ở lần chạy đầu tiên, cho các loại lấy theo ngày. Elton không tự giới hạn ngày bắt đầu.
- Later runs rescan: các lần chạy sau, Elton lấy từ ngày của lần chạy thành công gần nhất (theo giờ UTC), lùi lại số ngày này: Last 1 day, Last 3 days, Last 7 days, Last 30 days, Last 60 days hoặc Last 90 days. Để trống thì lùi 1 ngày (riêng Payment Account Balance Transaction lùi 30 ngày). Nhờ vậy đơn đã đổi trạng thái (thanh toán, giao hàng, huỷ, hoàn tiền…) vẫn được cập nhật.
Một số loại dữ liệu không theo hai tuỳ chọn ngày ở trên: chúng được lấy toàn bộ mỗi lần chạy. Cột Cách lấy ở mục 4 ghi rõ.
Bản ghi được cập nhật theo khoá của bảng: lấy lại cùng một bản ghi thì dòng cũ được thay, không bị nhân đôi.
Full reload lấy lại từ First run loads from; riêng Product lấy lại toàn bộ sản phẩm. Partial reload lấy lại khoảng ngày bạn chọn cho các loại lấy theo ngày:
- Order, Order Agreement, Abandoned Checkout, Customer Journey Summary: bản ghi có
updated_attrong khoảng đã chọn. - Customer, Product, Fulfillment Order: bản ghi có
updated_attừ ngày bắt đầu của khoảng đến hiện tại (ngày kết thúc không giới hạn dữ liệu lấy về). - Payment Account Balance Transaction: giao dịch có ngày tiền khả dụng (
available_on) từ ngày bắt đầu của khoảng. - Các loại lấy toàn bộ mỗi lần chạy (Collection, Location, Inventory, Payment Dispute, Staff Members) chạy như bình thường.
4. Shopify: dữ liệu được đồng bộ
Bảng có tên dạng shopify_<loại>_<shop name>, với shop name là Shop name của source đã chuẩn hoá: viết thường, dấu -, ., / và khoảng trắng đổi thành _, bỏ ký tự đặc biệt. Ví dụ Shop name elton-data-test cho bảng shopify_order_elton_data_test.
Connection có ngày bắt đầu chạy trước ngày 1/2/2025 ghi đơn hàng vào bảng shopify_order_<shop name>_v2 (thêm hậu tố _v2), ví dụ shopify_order_elton_data_test_v2. Các loại dữ liệu khác không có hậu tố này.
| Loại dữ liệu | Bảng | Khoá | Cách lấy | Phân vùng (partition) theo ngày |
|---|---|---|---|---|
| Order | shopify_order_<shop name> | id | Đơn có updated_at trong khoảng lấy | created_at |
| Order Agreement | shopify_order_agreement_<shop name> | id, agreement_type | Agreement của các đơn có updated_at trong khoảng lấy | happened_at |
| Fulfillment Order | shopify_fulfillment_order_<shop name> | id | Fulfillment order có updated_at từ đầu khoảng lấy | created_at |
| Product | shopify_product_<shop name> | id | Toàn bộ ở lần chạy đầu và Full reload, sau đó sản phẩm có updated_at theo Later runs rescan | created_at |
| Collection | shopify_collection_<shop name> | id | Toàn bộ, mỗi lần chạy | updated_at |
| Customer | shopify_customer_<shop name> | id | Khách hàng có updated_at từ đầu khoảng lấy | created_at |
| Location | shopify_location_<shop name> | id | Toàn bộ, mỗi lần chạy | created_at |
| Inventory (Latest) | shopify_inventory_<shop name> | inventory_item_id | Toàn bộ mặt hàng tồn kho, mỗi lần chạy | created_at |
| Inventory (Day) | shopify_inventory_<shop name> | inventory_item_id, elton_record_date | Snapshot mỗi ngày | created_at |
| Payment Dispute | shopify_payment_dispute_<shop name> | id | Toàn bộ, mỗi lần chạy | initiated_at |
| Payment Account Balance Transaction | shopify_payment_account_balance_transaction_<shop name> | id | Giao dịch có available_on từ đầu khoảng lấy | transaction_date |
| Customer Journey Summary | shopify_customer_journey_summary_<shop name> | order_id | Theo các đơn có updated_at trong khoảng lấy | created_at |
| Abandoned Checkout | shopify_abandoned_checkout_<shop name> | id | Checkout có updated_at trong khoảng lấy | created_at |
| Staff Members | shopify_staff_member_<shop name> | id | Toàn bộ, mỗi lần chạy |
"Khoảng lấy" là từ First run loads from ở lần chạy đầu, sau đó theo Later runs rescan (xem mục 3).
Cách lưu dữ liệu chung cho các bảng Shopify:
- Mã (
id,order_id,location_id…) là số: Elton đã bỏ tiền tốgid://shopify/...của Shopify, ví dụgid://shopify/Order/5432109876thành5432109876. Mã nằm trong chuỗi JSON cũng đã bỏ tiền tố, trừ khi có ghi chú khác. - Cột dạng object (ví dụ
customer,shipping_address) được lưu dạng chuỗi JSON. Cột dạng danh sách (ví dụline_items,variants) được lưu dạng mảng chuỗi (trên BigQuery làARRAY<STRING>), mỗi phần tử là một object JSON. DùngUNNESTđể tách từng phần tử vàJSON_VALUEđể đọc trường bên trong (xem mục 5). - Tên trường bên trong JSON viết dạng
snake_case(ví dụshop_money,currency_code), trừ các cột có ghi chú "giữ tên trường của Shopify" (dạngcamelCase, ví dụcurrencyCode). - Cột tiền có tên kết thúc bằng
_setlà chuỗi JSON có hai mức tiền:shop_money(tiền tệ của store) vàpresentment_money(tiền tệ khách thấy khi mua), mỗi mức gồmamountvàcurrency_code. Ví dụ đọc tổng tiền theo tiền tệ store:CAST(JSON_VALUE(total_price_set, '$.shop_money.amount') AS FLOAT64). - Các cột thời điểm kiểu
TIMESTAMPlà giờ UTC. - Cột
elton_created_at(thời điểm Elton lấy bản ghi) chỉ được ghi vào BigQuery khi connection dùng kiểu ghi Append. Với Merge (cập nhật theo khoá) và Overwrite, bảng ở BigQuery không có cột này.
Order
Bảng shopify_order_<shop name> (hoặc shopify_order_<shop name>_v2, xem mục 4): mỗi dòng là một đơn hàng. Elton lấy đơn có updated_at trong khoảng lấy, chia thành từng đoạn 7 ngày. Đơn đổi trạng thái sẽ được cập nhật ở lần chạy sau.
| Cột | Ý nghĩa |
|---|---|
id | Mã đơn (số), dùng để nối bảng |
name, confirmation_number, po_number | Tên đơn hiển thị trong Shopify Admin (ví dụ #1001), mã xác nhận, số PO |
created_at, updated_at, processed_at, closed_at, cancelled_at | Thời điểm tạo, cập nhật, xử lý, đóng, huỷ đơn |
display_financial_status | Trạng thái thanh toán, ví dụ PAID, PENDING, REFUNDED, PARTIALLY_REFUNDED |
display_fulfillment_status | Trạng thái giao hàng, ví dụ FULFILLED, UNFULFILLED, PARTIALLY_FULFILLED |
cancel_reason, cancellation | Lý do huỷ, và ghi chú huỷ của nhân viên (chuỗi JSON giữ tên trường của Shopify: staffNote) |
currency_code, presentment_currency_code | Tiền tệ của store, tiền tệ khách thấy khi mua |
total_price_set, current_total_price_set, original_total_price_set | Tổng tiền đơn; tổng tiền hiện tại (sau khi sửa đơn, hoàn trả); tổng tiền lúc tạo đơn |
subtotal_price_set, current_subtotal_price_set | Tạm tính, ban đầu và hiện tại |
total_discounts_set, current_total_discounts_set, current_cart_discount_amount_set | Tổng giảm giá, giảm giá hiện tại, giảm giá cấp giỏ hàng |
total_shipping_price_set, current_shipping_price_set | Phí vận chuyển |
total_tax_set, current_total_tax_set, tax_lines | Thuế |
total_refunded_set, total_received_set, total_outstanding_set, net_payment_set, total_tip_received_set | Đã hoàn, đã nhận, còn phải thu, thực nhận, tiền tip |
subtotal_line_items_quantity, current_subtotal_line_items_quantity | Số lượng sản phẩm trong đơn, ban đầu và hiện tại |
total_weight, current_total_weight | Tổng cân nặng |
customer | Khách hàng (chuỗi JSON): id, email, display_name, first_name, last_name, phone |
email | Email trên đơn |
billing_address, shipping_address | Địa chỉ thanh toán, giao hàng (chuỗi JSON): name, phone, address1, address2, city, province, country, country_code_v2, zip… |
line_items | Sản phẩm trong đơn (mảng JSON), xem các trường bên dưới. Tối đa 250 dòng sản phẩm mỗi đơn |
discount_codes, discount_code, discount_applications | Các mã giảm giá đã dùng, mã đầu tiên, và các khuyến mãi áp dụng (mảng JSON, tối đa 10) |
shipping_lines | Phương thức vận chuyển (mảng JSON, tối đa 10): title, code, source, carrier_identifier, current_discounted_price_set… |
refunds | Các lần hoàn tiền (mảng JSON, tối đa 100): id, created_at, note, total_refunded_set, duties, refund_line_items (mỗi phần tử có id, line_item, price_set) |
transactions | Giao dịch thanh toán (mảng JSON, tối đa 100): id, kind, status, gateway, amount_set, fees, processed_at, payment_id… |
fulfillment_orders | Các fulfillment order của đơn (mảng JSON, tối đa 50): id, location_id |
payment_gateway_names | Các cổng thanh toán |
source_name, source_identifier | Kênh tạo đơn và mã tham chiếu của kênh |
channel_information | Kênh bán (chuỗi JSON): id, channel_id. Trường channel_information bên trong luôn trống |
location_id | Điểm bán (location) của đơn bán tại cửa hàng (POS) |
staff_member | Nhân viên tạo đơn (chuỗi JSON id, email). Chỉ có khi bật App has read_users permission ở data source; nếu tắt thì luôn trống |
test | Đơn thử nghiệm. Lọc test = false khi tính doanh thu |
tags, note, custom_attributes | Thẻ (mảng), ghi chú, thuộc tính tuỳ chỉnh (mảng JSON key, value) |
risk | Đánh giá rủi ro gian lận (chuỗi JSON assessments, recommendation; bên trong assessments giữ tên trường của Shopify, ví dụ riskLevel) |
disputes | Tranh chấp thanh toán của đơn (mảng JSON id, initiated_as, status) |
Tất cả cột của shopify_order_<shop name>: id, name, created_at, updated_at, po_number, additional_fees, billing_address, billing_address_matches_shipping_address, cancellation, cancelled_at, cancel_reason, can_mark_as_paid, capturable, channel_information, client_ip, closed, closed_at, confirmation_number, confirmed, currency_code, current_cart_discount_amount_set, current_shipping_price_set, subtotal_line_items_quantity, current_subtotal_line_items_quantity, subtotal_price_set, current_subtotal_price_set, tax_lines, current_total_additional_fees_set, total_discounts_set, current_total_discounts_set, current_total_duties_set, current_total_price_set, current_total_tax_set, current_total_weight, custom_attributes, customer, customer_accepts_marketing, customer_locale, discount_applications, discount_code, discount_codes, display_financial_status, display_fulfillment_status, disputes, duties_included, edited, email, estimated_taxes, fulfillable, fully_paid, line_items, merchant_business_entity, net_payment_set, note, original_total_additional_fees_set, original_total_duties_set, original_total_price_set, payment_gateway_names, presentment_currency_code, processed_at, refundable, refund_discrepancy_set, refunds, requires_shipping, restockable, location_id, fulfillment_orders, shipping_address, shipping_lines, source_identifier, source_name, staff_member, tags, taxes_included, tax_exempt, test, total_capturable_set, total_outstanding_set, total_price_set, total_received_set, total_refunded_set, total_shipping_price_set, total_tax_set, total_tip_received_set, total_weight, unpaid, risk, transactions, elton_created_at
Các trường của mỗi sản phẩm trong line_items: id, sku, name, title, quantity, current_quantity, refundable_quantity, non_fulfillable_quantity, requires_shipping, restockable, product_id, discount_allocations, staff_member, total_discount_set, discounted_total_set, discounted_unit_price_after_all_discounts_set, discounted_unit_price_set, is_gift_card, original_total_set, original_unit_price_set, unfulfilled_discounted_total_set, unfulfilled_original_total_set, unfulfilled_quantity, vendor, variant (object id, display_name, title, barcode). quantity là số lượng lúc đặt, current_quantity là số lượng sau khi sửa đơn và hoàn trả.
Order Agreement
Bảng shopify_order_agreement_<shop name>: mỗi dòng là một agreement (sự kiện bán hàng) của một đơn: tạo đơn, sửa đơn, hoàn tiền… Dùng để tính doanh số theo thời điểm phát sinh (happened_at) thay vì theo ngày tạo đơn. Elton lấy agreement của các đơn có updated_at trong khoảng lấy, tối đa 80 agreement mỗi đơn và 250 dòng bán (sale) mỗi agreement.
| Cột | Ý nghĩa |
|---|---|
id | Mã agreement. Agreement khác loại có thể trùng mã, nên khoá của bảng gồm cả agreement_type |
agreement_type | Loại agreement, ví dụ OrderAgreement, RefundAgreement |
order_id, order_name, order_created_at | Đơn của agreement |
happened_at | Thời điểm agreement phát sinh |
reason | Lý do, ví dụ ORDER_CREATE, REFUND_CREATE |
app | App tạo agreement (chuỗi JSON id, title), ví dụ Online Store |
sales | Các dòng bán (mảng JSON): id, sale_type (ví dụ ProductSale, ShippingLineSale), action_type (ví dụ ORDER), line_type (ví dụ PRODUCT, SHIPPING), quantity, total_amount, total_tax_amount, total_discount_amount_before_taxes, total_discount_amount_after_taxes |
Dòng bán trong sales không có mã dòng sản phẩm hay mã sản phẩm, nên bảng này chỉ nối được với đơn qua order_id.
Tất cả cột của shopify_order_agreement_<shop name>: id, agreement_type, order_id, order_name, order_created_at, happened_at, reason, app, sales, elton_created_at
Fulfillment Order
Bảng shopify_fulfillment_order_<shop name>: mỗi dòng là một fulfillment order, tức phần hàng của một đơn được giao từ một location.
| Cột | Ý nghĩa |
|---|---|
id | Mã fulfillment order |
order_id | Đơn chứa fulfillment order |
location_id | Location được giao xử lý |
status, request_status | Trạng thái, và trạng thái yêu cầu gửi bên xử lý đơn |
fulfill_at, fulfill_by | Thời điểm sẵn sàng xử lý, hạn xử lý |
delivery_method | Phương thức giao (chuỗi JSON): id, method_type, service_code, source_reference, min_delivery_date_time, max_delivery_date_time |
line_items | Sản phẩm (mảng JSON): line_item_id (mã dòng sản phẩm trong line_items của đơn), inventory_item_id, sku, product_title, variant_title, vendor, total_quantity, remaining_quantity, requires_shipping. Trường id trong mỗi phần tử luôn trống |
Tất cả cột của shopify_fulfillment_order_<shop name>: id, created_at, updated_at, fulfill_at, fulfill_by, status, request_status, order_id, location_id, delivery_method, line_items, elton_created_at
Product
Bảng shopify_product_<shop name>: mỗi dòng là một sản phẩm; các biến thể (variant: màu, size…) nằm trong cột variants. Lần chạy đầu và Full reload lấy toàn bộ sản phẩm, không theo First run loads from. Các lần sau lấy sản phẩm có updated_at theo Later runs rescan.
| Cột | Ý nghĩa |
|---|---|
id | Mã sản phẩm, dùng để nối bảng |
title, handle, vendor, product_type | Tên, đường dẫn (handle), nhà cung cấp, loại sản phẩm |
status | Trạng thái, ví dụ ACTIVE, DRAFT, ARCHIVED |
tags | Thẻ, nối bằng dấu phẩy thành một chuỗi |
category | Danh mục chuẩn của Shopify (chuỗi JSON giữ tên trường của Shopify: id còn tiền tố gid://shopify/TaxonomyCategory/, fullName, name, level) |
created_at, updated_at, published_at | Thời điểm tạo, cập nhật, đăng bán |
body_html | Mô tả (HTML) |
variants | Biến thể (mảng JSON, tối đa 250): id, sku, barcode, title, display_name, price, compare_at_price, inventory_quantity, available_for_sale, taxable, created_at, updated_at |
collections | Các collection chứa sản phẩm (mảng JSON id) |
media | Ảnh, video (mảng JSON): id, alt, media_content_type, status |
metafields | Metafield (mảng JSON): id, namespace, key, type, value, definition (id, name), created_at, updated_at |
options | Thuộc tính biến thể. Hiện mỗi phần tử chỉ có id; tên và giá trị thuộc tính luôn trống. Dùng title trong variants để biết biến thể |
Tất cả cột của shopify_product_<shop name>: id, title, created_at, updated_at, published_at, body_html, vendor, product_type, handle, template_suffix, status, tags, category, variants, options, media, collections, metafields, elton_created_at
Collection
Bảng shopify_collection_<shop name>: mỗi dòng là một collection (nhóm sản phẩm). Elton lấy toàn bộ collection mỗi lần chạy, cả smart collection lẫn custom collection.
| Cột | Ý nghĩa |
|---|---|
id, title, handle, description | Mã, tên, đường dẫn, mô tả |
collection_type | smart (tự gom sản phẩm theo điều kiện) hoặc custom (chọn tay) |
products_count | Số sản phẩm (chuỗi JSON count, precision) |
updated_at | Thời điểm cập nhật |
Bảng này không có danh sách sản phẩm. Sản phẩm nào thuộc collection nào xem ở cột collections của bảng shopify_product_<shop name>.
Tất cả cột của shopify_collection_<shop name>: id, handle, title, updated_at, description, template_suffix, products_count, collection_type, elton_created_at
Customer
Bảng shopify_customer_<shop name>: mỗi dòng là một khách hàng. Lần chạy đầu chỉ lấy khách hàng có updated_at từ First run loads from, nên khách hàng không thay đổi gì từ trước ngày đó không có trong bảng. Muốn lấy đủ, chọn First run loads from đủ xa rồi chạy Full reload.
| Cột | Ý nghĩa |
|---|---|
id | Mã khách hàng, dùng để nối bảng |
email, phone, first_name, last_name | Thông tin liên hệ |
created_at, updated_at | Thời điểm tạo, cập nhật |
orders_count, total_spent | Số đơn, tổng chi tiêu |
currency | Luôn trống |
last_order_id, last_order_name | Mã đơn gần nhất (dạng chuỗi), tên đơn gần nhất |
state | Trạng thái tài khoản khách hàng, ví dụ ENABLED, DISABLED, INVITED |
verified_email, tax_exempt, tax_exemptions | Email đã xác minh, miễn thuế |
tags | Thẻ, nối bằng dấu phẩy thành một chuỗi |
addresses | Địa chỉ (mảng JSON): id, name, phone, address1, address2, city, province, country, country_code_v2, zip… |
statistics | Phân nhóm của Shopify (chuỗi JSON giữ tên trường của Shopify: predictedSpendTier, rfmGroup) |
Tất cả cột của shopify_customer_<shop name>: id, email, created_at, updated_at, first_name, last_name, state, orders_count, total_spent, last_order_id, last_order_name, note, verified_email, multipass_identifier, tax_exempt, tags, currency, phone, addresses, tax_exemptions, statistics, elton_created_at
Location
Bảng shopify_location_<shop name>: mỗi dòng là một location (kho, cửa hàng, điểm xử lý đơn). Lấy toàn bộ mỗi lần chạy.
| Cột | Ý nghĩa |
|---|---|
id, name | Mã, tên location |
active | Location đang hoạt động |
address1, address2, city, province, province_code, country, country_code, zip, phone | Địa chỉ |
formatted | Địa chỉ đầy đủ, các dòng nối bằng dấu phẩy |
latitude, longitude | Toạ độ |
Tất cả cột của shopify_location_<shop name>: id, name, created_at, updated_at, address1, address2, city, country, country_code, formatted, latitude, longitude, phone, province, province_code, zip, active, elton_created_at
Inventory
Bảng shopify_inventory_<shop name>: mỗi dòng là một mặt hàng tồn kho (inventory item, ứng với một biến thể sản phẩm), kèm số tồn ở từng location trong cột inventory_levels.
Elton lấy toàn bộ mặt hàng tồn kho mỗi lần chạy (qua một bulk operation của Shopify), không theo First run loads from hay Later runs rescan: Shopify không cập nhật updated_at của mặt hàng khi số tồn thay đổi, nên không lấy theo ngày được.
Theo Inventory granularity của connection:
- Latest: khoá là
inventory_item_id. Mỗi lần chạy thay dòng cũ bằng số tồn mới nhất. - Day: khoá là
inventory_item_idvàelton_record_date(ngày chạy, theo UTC). Chạy nhiều lần trong ngày thì dòng của ngày đó được thay bằng lần chạy mới nhất; các ngày trước được giữ lại, nên bạn xem được tồn kho theo từng ngày.
| Cột | Ý nghĩa |
|---|---|
inventory_item_id | Mã mặt hàng tồn kho |
sku | SKU, dùng để nối với sku trong variants của bảng sản phẩm |
unit_cost | Giá vốn (chuỗi JSON giữ tên trường của Shopify: amount, currencyCode) |
tracked, requires_shipping | Có theo dõi tồn kho không, có cần giao hàng không |
country_code_of_origin, province_code_of_origin, harmonized_system_code, country_harmonized_system_codes | Xuất xứ và mã HS. Nếu Shopify từ chối lấy mã HS theo quốc gia, Elton lấy lại không kèm mã này và country_harmonized_system_codes là mảng rỗng |
inventory_levels | Tồn kho theo location (mảng JSON): id, location_id, created_at, updated_at, quantities |
elton_record_date | Ngày chụp số tồn. Chỉ có khi Inventory granularity là Day |
quantities trong mỗi phần tử của inventory_levels là object có tên trạng thái và số lượng, gồm incoming, on_hand, available, committed, reserved, damaged, safety_stock, quality_control. Ý nghĩa từng trạng thái: Shopify Inventory States.
Ví dụ trên BigQuery, tồn kho on_hand và available theo từng location:
SELECT
i.inventory_item_id,
i.sku,
JSON_VALUE(il, '$.location_id') AS location_id,
JSON_VALUE(il, '$.updated_at') AS updated_at,
CAST(JSON_VALUE(il, '$.quantities.on_hand') AS INT64) AS on_hand,
CAST(JSON_VALUE(il, '$.quantities.available') AS INT64) AS available
FROM `dataset.shopify_inventory_elton_data_test` i,
UNNEST(i.inventory_levels) AS il;
Tất cả cột của shopify_inventory_<shop name> (Latest): inventory_item_id, sku, created_at, updated_at, requires_shipping, unit_cost, country_code_of_origin, province_code_of_origin, harmonized_system_code, tracked, country_harmonized_system_codes, inventory_levels, elton_created_at
Tất cả cột của shopify_inventory_<shop name> (Day): inventory_item_id, sku, created_at, updated_at, requires_shipping, unit_cost, country_code_of_origin, province_code_of_origin, harmonized_system_code, tracked, country_harmonized_system_codes, inventory_levels, elton_record_date, elton_created_at
Payment Dispute
Bảng shopify_payment_dispute_<shop name>: mỗi dòng là một tranh chấp thanh toán (chargeback, inquiry) trên Shopify Payments. Lấy toàn bộ mỗi lần chạy. Store không dùng Shopify Payments thì bảng trống.
| Cột | Ý nghĩa |
|---|---|
id | Mã tranh chấp |
order_id | Đơn bị tranh chấp |
type, status | Loại tranh chấp và trạng thái |
amount | Số tiền (chuỗi JSON amount, currency_code) |
reason_details | Lý do (chuỗi JSON reason, network_reason_code) |
initiated_at, evidence_due_by, evidence_sent_on, finalized_on | Thời điểm mở, hạn nộp bằng chứng, ngày gửi bằng chứng, ngày kết thúc |
Tất cả cột của shopify_payment_dispute_<shop name>: id, initiated_at, evidence_due_by, evidence_sent_on, finalized_on, status, amount, type, order_id, reason_details, elton_created_at
Payment Account Balance Transaction
Bảng shopify_payment_account_balance_transaction_<shop name>: mỗi dòng là một giao dịch làm thay đổi số dư tài khoản Shopify Payments (tiền bán hàng, phí, hoàn tiền, payout…). Elton lấy giao dịch có ngày tiền khả dụng (available_on) từ đầu khoảng lấy. Later runs rescan để trống thì lùi 30 ngày.
| Cột | Ý nghĩa |
|---|---|
id | Mã giao dịch số dư |
transaction_date | Thời điểm giao dịch |
type, source_type | Loại giao dịch và loại nguồn phát sinh |
amount, fee | Số tiền và phí (chuỗi JSON amount, currency_code) |
associated_order | Đơn liên quan (chuỗi JSON id, name) |
source_order_transaction_id | Mã giao dịch thanh toán của đơn, khớp với id trong cột transactions của bảng đơn hàng |
Tất cả cột của shopify_payment_account_balance_transaction_<shop name>: id, transaction_date, type, source_type, source_order_transaction_id, associated_order, fee, amount, elton_created_at
Customer Journey Summary
Bảng shopify_customer_journey_summary_<shop name>: mỗi dòng là hành trình của khách trước khi đặt một đơn (lần truy cập đầu, lần cuối, nguồn, UTM). Elton lấy cho các đơn có updated_at trong khoảng lấy, qua một bulk operation của Shopify.
| Cột | Ý nghĩa |
|---|---|
order_id | Mã đơn (khoá của bảng) |
customer_id | Mã khách hàng |
created_at, updated_at | Thời điểm tạo, cập nhật của đơn |
customer_order_index | Đây là đơn thứ mấy của khách |
days_to_conversion | Số ngày từ lần truy cập đầu đến khi đặt đơn |
first_visit, last_visit | Lần truy cập đầu và cuối (chuỗi JSON giữ tên trường của Shopify): landingPage, referrerUrl, source, sourceType, sourceDescription, referralCode, occurredAt, utmParameters (campaign, content, medium, source, term), marketingEvent (utmCampaign, utmMedium, utmSource, marketingChannelType…) |
moments, moments_count | Các lần tương tác (mảng JSON occurred_at), và số lần (chuỗi JSON count, precision) |
ready | Shopify đã tính xong hành trình chưa |
Tất cả cột của shopify_customer_journey_summary_<shop name>: order_id, customer_id, created_at, updated_at, customer_order_index, days_to_conversion, first_visit, last_visit, moments, moments_count, ready, elton_created_at
Abandoned Checkout
Bảng shopify_abandoned_checkout_<shop name>: mỗi dòng là một checkout bị bỏ dở (khách nhập thông tin nhưng chưa đặt đơn).
| Cột | Ý nghĩa |
|---|---|
id, name | Mã, tên checkout |
created_at, updated_at, completed_at | Thời điểm tạo, cập nhật, hoàn tất |
abandoned_checkout_url | Link để khách quay lại hoàn tất mua |
customer | Khách hàng (chuỗi JSON id, email, display_name) |
billing_address | Địa chỉ thanh toán (chuỗi JSON) |
shipping_address | Luôn trống |
line_items | Sản phẩm (mảng JSON): id, sku, title, variant_title, product_id, variant (id, display_name, title, barcode), components, custom_attributes, discount_allocations, original_unit_price_set, original_total_price_set, discounted_unit_price_set, discounted_total_price_set, discounted_unit_price_with_code_discount, discounted_total_price_with_code_discount |
subtotal_price_set, total_line_items_price_set, total_price_set, total_tax_set, total_duties_set | Các tổng tiền (chuỗi JSON shop_money, presentment_money) |
total_discount_set | Tổng giảm giá. Cột này giữ tên trường của Shopify: đọc bằng $.shopMoney.amount, không phải $.shop_money.amount |
Tất cả cột của shopify_abandoned_checkout_<shop name>: id, name, created_at, updated_at, completed_at, abandoned_checkout_url, note, billing_address, shipping_address, custom_attributes, customer, subtotal_price_set, taxes_included, tax_lines, total_discount_set, total_duties_set, total_line_items_price_set, total_price_set, total_tax_set, line_items, elton_created_at
Staff Members
Bảng shopify_staff_member_<shop name>: mỗi dòng là một nhân viên (staff account) của store. Lấy toàn bộ mỗi lần chạy.
Cần app có scope read_users, và chỉ store gói Advanced hoặc Plus mới lấy được nhân viên. Khi chọn loại này, Elton lấy nó trước các loại khác, để lần chạy báo lỗi ngay nếu store không cho lấy.
| Cột | Ý nghĩa |
|---|---|
id, name, first_name, last_name, email, phone | Thông tin nhân viên |
account_type | Loại tài khoản nhân viên |
active, exists, is_shop_owner | Còn hoạt động, còn tồn tại, là chủ store |
locale | Ngôn ngữ |
Tất cả cột của shopify_staff_member_<shop name>: id, name, first_name, last_name, email, phone, account_type, active, exists, is_shop_owner, locale, elton_created_at
5. Quan hệ giữa các bảng
Các bảng Shopify nối với nhau qua mã đơn, mã khách hàng, mã sản phẩm, mã biến thể và mã location. Hậu tố <shop name> ở các bảng cần nối phải là của cùng một store.
| Bảng | Nối với bảng | Điều kiện nối | Quan hệ |
|---|---|---|---|
shopify_order_<shop name> | shopify_customer_<shop name> | JSON_VALUE(customer, '$.id') = CAST(id AS STRING) | nhiều đơn – 1 khách hàng |
shopify_order_<shop name> | shopify_product_<shop name> | line_items[].product_id = id (tách mảng line_items) | nhiều sản phẩm trong 1 đơn |
shopify_order_<shop name> | shopify_product_<shop name> (cột variants) | line_items[].variant.id = variants[].id (tách cả hai mảng) | 1 dòng sản phẩm – 1 biến thể |
shopify_order_<shop name> | shopify_order_agreement_<shop name> | id = order_id | 1 đơn – nhiều agreement |
shopify_order_<shop name> | shopify_fulfillment_order_<shop name> | id = order_id | 1 đơn – nhiều fulfillment order |
shopify_order_<shop name> | shopify_customer_journey_summary_<shop name> | id = order_id | 1 – 1 |
shopify_order_<shop name> | shopify_payment_dispute_<shop name> | id = order_id | 1 đơn – nhiều tranh chấp |
shopify_order_<shop name> | shopify_payment_account_balance_transaction_<shop name> | CAST(id AS STRING) = JSON_VALUE(associated_order, '$.id') | 1 đơn – nhiều giao dịch số dư |
shopify_order_<shop name> | shopify_location_<shop name> | location_id = id (đơn POS) | nhiều đơn – 1 location |
shopify_order_<shop name> | shopify_staff_member_<shop name> | JSON_VALUE(staff_member, '$.id') = CAST(id AS STRING) | nhiều đơn – 1 nhân viên |
shopify_fulfillment_order_<shop name> | shopify_location_<shop name> | location_id = id | nhiều – 1 |
shopify_fulfillment_order_<shop name> | shopify_inventory_<shop name> | line_items[].inventory_item_id = inventory_item_id | 1 dòng – 1 mặt hàng tồn kho |
shopify_inventory_<shop name> | shopify_location_<shop name> | inventory_levels[].location_id = id | 1 mặt hàng – nhiều location |
shopify_inventory_<shop name> | shopify_product_<shop name> (cột variants) | sku = variants[].sku | 1 mặt hàng – 1 biến thể (khi SKU không trùng) |
shopify_product_<shop name> | shopify_collection_<shop name> | collections[].id = id | nhiều – nhiều |
shopify_customer_<shop name> | shopify_order_<shop name> | last_order_id = CAST(id AS STRING) | 1 khách hàng – đơn gần nhất |
shopify_customer_journey_summary_<shop name> | shopify_customer_<shop name> | customer_id = id | nhiều – 1 |
shopify_abandoned_checkout_<shop name> | shopify_customer_<shop name> | JSON_VALUE(customer, '$.id') = CAST(id AS STRING) | nhiều – 1 |
Lưu ý khi nối:
- Các cột mã ở cấp bảng (
id,order_id,location_id,customer_id,inventory_item_id) là số (INTEGER). Giá trị đọc từ chuỗi JSON bằngJSON_VALUElà chuỗi, nên cầnCASTkhi so sánh. Riênglast_order_idcủa bảng khách hàng là chuỗi. - Mã sản phẩm có tên khác nhau:
idởshopify_product_<shop name>,product_idtrongline_itemscủa đơn và của abandoned checkout. - Bảng tồn kho không có mã biến thể hay mã sản phẩm; nối với sản phẩm qua SKU.
- Ví dụ trên BigQuery, số lượng bán và doanh thu theo sản phẩm (tiền tệ store), bỏ đơn thử nghiệm và đơn đã huỷ:
SELECT p.id AS product_id,
p.title,
SUM(CAST(JSON_VALUE(li, '$.current_quantity') AS INT64)) AS quantity,
SUM(CAST(JSON_VALUE(li, '$.discounted_total_set.shop_money.amount') AS FLOAT64)) AS revenue
FROM `dataset.shopify_order_elton_data_test` o,
UNNEST(o.line_items) AS li
JOIN `dataset.shopify_product_elton_data_test` p
ON p.id = CAST(JSON_VALUE(li, '$.product_id') AS INT64)
WHERE o.test = false
AND o.cancelled_at IS NULL
GROUP BY product_id, p.title
ORDER BY revenue DESC;
6. Lỗi thường gặp
| Lỗi | Nguyên nhân và cách xử lý |
|---|---|
Shopify authentication failed! Please double check the shop name and API password/credentials in the datasource before continuing. | Shopify từ chối thông tin xác thực (lỗi 401/403). Kiểm tra Shop name, App type và Client ID/Client Secret hoặc API Password ở data source (mục 2). |
Failed to connect to Shopify shop '<shop name>'! Please double check the shop name in the datasource. | Không kết nối được tới <Shop name>.myshopify.com. Kiểm tra Shop name: chỉ phần tên store, ví dụ elton-data-test, không kèm https:// hay .myshopify.com. |
Lỗi có 404 Client Error: Not Found và URL chứa myshopify.com/admin/api | Shop name sai. Lấy lại từ URL Shopify Admin như ở mục 2. |
API Password has not been config! Please double check in the datasource before continuing. | Data source dùng Custom app (legacy) nhưng chưa có API Password. Sửa data source và điền token, hoặc đổi sang Dev Dashboard app. |
Shopify rejected the client credentials grant for shop '<shop name>' with 'shop_not_permitted'… | Store không thuộc cùng tổ chức Shopify với app trong Dev Dashboard. Tạo app trong Dev Dashboard của tổ chức sở hữu store (cách A). |
Failed to get Shopify access token for shop '<shop name>' (status …) | Shopify không cấp token từ Client ID và Client Secret. Kiểm tra lại hai giá trị này (Client Secret có thể đã đổi), và app đã được cài trên store. |
Shopify access token is invalid or expired and cannot be refreshed for API password auth. Please re-check the API password in the datasource. | Token của custom app (legacy) đã bị thu hồi hoặc thay. Cập nhật API Password mới. |
Shopify denied access to field '<field>' (needs '<scope>'): the app installed on the store is missing the required access scope… | App thiếu scope cho loại dữ liệu đang lấy. Thêm scope theo bảng quyền, rồi cài lại hoặc duyệt lại app trên store. |
Shopify denied access to field 'staffMember'… | Đã bật App has read_users permission nhưng app không có scope read_users. Thêm scope, hoặc tắt lựa chọn này ở data source. |
Shopify denied access to field 'staffMembers' (needs 'read_users')… | Đã chọn Staff Members nhưng app thiếu read_users, hoặc gói Shopify của store không cho lấy nhân viên (chỉ Advanced và Plus được). Thêm scope, hoặc bỏ chọn Staff Members. |
Shopify bulk operation … ended FAILED (errorCode=ACCESS_DENIED): the app installed on the store is missing the '<scope>' access scope. | Lỗi quyền khi lấy Inventory (read_inventory) hoặc Customer Journey Summary (read_orders). Thêm scope ghi trong lỗi. |
Shopify rejected the bulk operation: … hoặc Shopify bulk operation … ended … (không phải ACCESS_DENIED) | Shopify từ chối hoặc dừng bulk operation dùng cho Inventory và Customer Journey Summary. Xem chi tiết trong lỗi, rồi chạy lại connection sau ít phút. |
Failed to get data from Shopify after 10 retries. | Shopify giới hạn tốc độ gọi API (throttled) hoặc lỗi tạm thời; Elton đã đợi 15 giây và thử lại 10 lần. Chạy lại sau, hoặc giảm tần suất chạy. |
| Bảng mới xuất hiện, dữ liệu mới không vào bảng cũ | Shop name của data source đã đổi, nên tên bảng đổi theo (xem mục 4). |
Không thấy bảng shopify_order_<shop name>, chỉ có shopify_order_<shop name>_v2 | Connection có ngày bắt đầu chạy trước ngày 1/2/2025 ghi đơn vào bảng có hậu tố _v2 (xem mục 4). |
| Thiếu đơn hoặc khách hàng cũ | Lần chạy đầu chỉ lấy bản ghi có updated_at từ First run loads from. Sửa ngày này rồi chạy Full reload. |
Cột staff_member luôn trống | Chưa bật App has read_users permission ở data source. |
Cách tính Billable Pipeline
Cách tính phí theo số pipeline của từng loại source xem ở đây.