Skip to main content

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 ở EltonDùng khiThô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 DashboardClient ID và Client Secret (cách A)
Custom app (legacy)Store đã có sẵn custom app tạo trong Shopify AdminAPI Password, tức Admin API access token (cách B)
warning

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)​

  1. Vào Shopify Dev Dashboard, mở tab Apps và bấm Create app. Đặt tên app, ví dụ Elton Data Integration.
  2. Ở 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.
  3. Cài app vào store cần lấy dữ liệu (chọn Install và chọn đúng store).
  4. 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.

note

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:

  1. Vào Settings.

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

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

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

  1. 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.

  1. Bấm Install app.

  1. 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 ở EltonScope cần có
Order, Order Agreement, Abandoned Checkout, Customer Journey Summaryread_orders
Customerread_customers
Product, Collectionread_products
Inventoryread_inventory
Locationread_locations
Payment Disputeread_shopify_payments_disputes
Payment Account Balance Transactionread_shopify_payments_accounts và read_shopify_payments_payouts
Staff Membersread_users
Fulfillment OrderQuyề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​

  1. Vào Data Sources → Create data source, ở ô Type chọn Shopify.
  2. Điền form:
TrườngGiá trị
NameTên hiển thị của source, ví dụ Elton Shopify
DescriptionMô tả, không bắt buộc
Shop nameBắ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 typeDev Dashboard app (mặc định khi tạo mới) hoặc Custom app (legacy). Xem bước 1
Client IDChỉ hiện khi App type là Dev Dashboard app. Client ID của app (cách A)
Client SecretChỉ hiện khi App type là Dev Dashboard app. Client Secret của app
API PasswordChỉ hiện khi App type là Custom app (legacy). Admin API access token của custom app (cách B)
Shopify planGó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 permissionBậ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
  1. 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.

note

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_at trong khoảng đã chọn.
  • Customer, Product, Fulfillment Order: bản ghi có updated_at từ 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.

note

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ệuBảngKhoáCách lấyPhân vùng (partition) theo ngày
Ordershopify_order_<shop name>idĐơn có updated_at trong khoảng lấycreated_at
Order Agreementshopify_order_agreement_<shop name>id, agreement_typeAgreement của các đơn có updated_at trong khoảng lấyhappened_at
Fulfillment Ordershopify_fulfillment_order_<shop name>idFulfillment order có updated_at từ đầu khoảng lấycreated_at
Productshopify_product_<shop name>idToàn bộ ở lần chạy đầu và Full reload, sau đó sản phẩm có updated_at theo Later runs rescancreated_at
Collectionshopify_collection_<shop name>idToàn bộ, mỗi lần chạyupdated_at
Customershopify_customer_<shop name>idKhách hàng có updated_at từ đầu khoảng lấycreated_at
Locationshopify_location_<shop name>idToàn bộ, mỗi lần chạycreated_at
Inventory (Latest)shopify_inventory_<shop name>inventory_item_idToàn bộ mặt hàng tồn kho, mỗi lần chạycreated_at
Inventory (Day)shopify_inventory_<shop name>inventory_item_id, elton_record_dateSnapshot mỗi ngàycreated_at
Payment Disputeshopify_payment_dispute_<shop name>idToàn bộ, mỗi lần chạyinitiated_at
Payment Account Balance Transactionshopify_payment_account_balance_transaction_<shop name>idGiao dịch có available_on từ đầu khoảng lấytransaction_date
Customer Journey Summaryshopify_customer_journey_summary_<shop name>order_idTheo các đơn có updated_at trong khoảng lấycreated_at
Abandoned Checkoutshopify_abandoned_checkout_<shop name>idCheckout có updated_at trong khoảng lấycreated_at
Staff Membersshopify_staff_member_<shop name>idToà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/5432109876 thành 5432109876. 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ùng UNNEST để 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ạng camelCase, ví dụ currencyCode).
  • Cột tiền có tên kết thúc bằng _set là 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ồm amount và 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 TIMESTAMP là 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
idMã đơn (số), dùng để nối bảng
name, confirmation_number, po_numberTê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_atThời điểm tạo, cập nhật, xử lý, đóng, huỷ đơn
display_financial_statusTrạng thái thanh toán, ví dụ PAID, PENDING, REFUNDED, PARTIALLY_REFUNDED
display_fulfillment_statusTrạng thái giao hàng, ví dụ FULFILLED, UNFULFILLED, PARTIALLY_FULFILLED
cancel_reason, cancellationLý 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_codeTiền tệ của store, tiền tệ khách thấy khi mua
total_price_set, current_total_price_set, original_total_price_setTổ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_setTạm tính, ban đầu và hiện tại
total_discounts_set, current_total_discounts_set, current_cart_discount_amount_setTổ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_setPhí vận chuyển
total_tax_set, current_total_tax_set, tax_linesThuế
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_quantitySố lượng sản phẩm trong đơn, ban đầu và hiện tại
total_weight, current_total_weightTổng cân nặng
customerKhách hàng (chuỗi JSON): id, email, display_name, first_name, last_name, phone
emailEmail 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_itemsSả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_applicationsCá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_linesPhương thức vận chuyển (mảng JSON, tối đa 10): title, code, source, carrier_identifier, current_discounted_price_set…
refundsCá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)
transactionsGiao dịch thanh toán (mảng JSON, tối đa 100): id, kind, status, gateway, amount_set, fees, processed_at, payment_id…
fulfillment_ordersCác fulfillment order của đơn (mảng JSON, tối đa 50): id, location_id
payment_gateway_namesCác cổng thanh toán
source_name, source_identifierKênh tạo đơn và mã tham chiếu của kênh
channel_informationKê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_memberNhâ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_attributesThẻ (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)
disputesTranh 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
idMã agreement. Agreement khác loại có thể trùng mã, nên khoá của bảng gồm cả agreement_type
agreement_typeLoại agreement, ví dụ OrderAgreement, RefundAgreement
order_id, order_name, order_created_atĐơn của agreement
happened_atThời điểm agreement phát sinh
reasonLý do, ví dụ ORDER_CREATE, REFUND_CREATE
appApp tạo agreement (chuỗi JSON id, title), ví dụ Online Store
salesCá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
idMã fulfillment order
order_idĐơn chứa fulfillment order
location_idLocation được giao xử lý
status, request_statusTrạng thái, và trạng thái yêu cầu gửi bên xử lý đơn
fulfill_at, fulfill_byThời điểm sẵn sàng xử lý, hạn xử lý
delivery_methodPhương thức giao (chuỗi JSON): id, method_type, service_code, source_reference, min_delivery_date_time, max_delivery_date_time
line_itemsSả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
idMã sản phẩm, dùng để nối bảng
title, handle, vendor, product_typeTên, đường dẫn (handle), nhà cung cấp, loại sản phẩm
statusTrạng thái, ví dụ ACTIVE, DRAFT, ARCHIVED
tagsThẻ, nối bằng dấu phẩy thành một chuỗi
categoryDanh 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_atThời điểm tạo, cập nhật, đăng bán
body_htmlMô tả (HTML)
variantsBiế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
collectionsCác collection chứa sản phẩm (mảng JSON id)
mediaẢnh, video (mảng JSON): id, alt, media_content_type, status
metafieldsMetafield (mảng JSON): id, namespace, key, type, value, definition (id, name), created_at, updated_at
optionsThuộ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, descriptionMã, tên, đường dẫn, mô tả
collection_typesmart (tự gom sản phẩm theo điều kiện) hoặc custom (chọn tay)
products_countSố sản phẩm (chuỗi JSON count, precision)
updated_atThờ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
idMã khách hàng, dùng để nối bảng
email, phone, first_name, last_nameThông tin liên hệ
created_at, updated_atThời điểm tạo, cập nhật
orders_count, total_spentSố đơn, tổng chi tiêu
currencyLuôn trống
last_order_id, last_order_nameMã đơn gần nhất (dạng chuỗi), tên đơn gần nhất
stateTrạng thái tài khoản khách hàng, ví dụ ENABLED, DISABLED, INVITED
verified_email, tax_exempt, tax_exemptionsEmail đã xác minh, miễn thuế
tagsThẻ, 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…
statisticsPhâ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, nameMã, tên location
activeLocation đ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, longitudeToạ độ

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_id và 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_idMã mặt hàng tồn kho
skuSKU, dùng để nối với sku trong variants của bảng sản phẩm
unit_costGiá vốn (chuỗi JSON giữ tên trường của Shopify: amount, currencyCode)
tracked, requires_shippingCó 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_codesXuấ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_levelsTồn kho theo location (mảng JSON): id, location_id, created_at, updated_at, quantities
elton_record_dateNgà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
idMã tranh chấp
order_idĐơn bị tranh chấp
type, statusLoại tranh chấp và trạng thái
amountSố tiền (chuỗi JSON amount, currency_code)
reason_detailsLý do (chuỗi JSON reason, network_reason_code)
initiated_at, evidence_due_by, evidence_sent_on, finalized_onThờ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
idMã giao dịch số dư
transaction_dateThời điểm giao dịch
type, source_typeLoại giao dịch và loại nguồn phát sinh
amount, feeSố tiền và phí (chuỗi JSON amount, currency_code)
associated_orderĐơn liên quan (chuỗi JSON id, name)
source_order_transaction_idMã 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_idMã đơn (khoá của bảng)
customer_idMã khách hàng
created_at, updated_atThờ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_conversionSố ngày từ lần truy cập đầu đến khi đặt đơn
first_visit, last_visitLầ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_countCác lần tương tác (mảng JSON occurred_at), và số lần (chuỗi JSON count, precision)
readyShopify đã 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, nameMã, tên checkout
created_at, updated_at, completed_atThời điểm tạo, cập nhật, hoàn tất
abandoned_checkout_urlLink để khách quay lại hoàn tất mua
customerKhách hàng (chuỗi JSON id, email, display_name)
billing_addressĐịa chỉ thanh toán (chuỗi JSON)
shipping_addressLuôn trống
line_itemsSả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_setCác tổng tiền (chuỗi JSON shop_money, presentment_money)
total_discount_setTổ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, phoneThông tin nhân viên
account_typeLoại tài khoản nhân viên
active, exists, is_shop_ownerCòn hoạt động, còn tồn tại, là chủ store
localeNgô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ảngNối với bảngĐiều kiện nốiQuan 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_id1 đơn – nhiều agreement
shopify_order_<shop name>shopify_fulfillment_order_<shop name>id = order_id1 đơn – nhiều fulfillment order
shopify_order_<shop name>shopify_customer_journey_summary_<shop name>id = order_id1 – 1
shopify_order_<shop name>shopify_payment_dispute_<shop name>id = order_id1 đơ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 = idnhiều – 1
shopify_fulfillment_order_<shop name>shopify_inventory_<shop name>line_items[].inventory_item_id = inventory_item_id1 dòng – 1 mặt hàng tồn kho
shopify_inventory_<shop name>shopify_location_<shop name>inventory_levels[].location_id = id1 mặt hàng – nhiều location
shopify_inventory_<shop name>shopify_product_<shop name> (cột variants)sku = variants[].sku1 mặt hàng – 1 biến thể (khi SKU không trùng)
shopify_product_<shop name>shopify_collection_<shop name>collections[].id = idnhiề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 = idnhiề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ằng JSON_VALUE là chuỗi, nên cần CAST khi so sánh. Riêng last_order_id củ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_id trong line_items củ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ỗiNguyê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/apiShop 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>_v2Connection 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ốngChư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.