Skip to main content
Load your orders, customers, product variants and refunds into the hook tables with a scheduled query that runs every night. A hook table is an append-only table in your Eyk BigQuery project that Eyk reads in its night run. You write rows into it with a normal INSERT.

Before you start

You need:
  • The Custom data page, read once.
  • A BigQuery project that holds your source data and can run scheduled queries.
  • The Custom BigQuery source added in Eyk under Sources, and write access to the hook tables. Ask your Eyk contact person if you need help with this step.
Setup has two parts. First you confirm the tables and shape one entity, then you schedule the inserts.

Tables

1

Confirm the tables

Open the _import dataset in the BigQuery console. All 6 tables are there, with the columns listed under Columns. Run a SELECT on one of them to confirm you have access.
2

Shape your product variants

Write a SELECT over your catalog that returns one row per variant, with every column cast to the table type. id must be the same value your order lines carry in variant_id. Categories are arrays of segments, never a joined string.
3

Insert 10 rows and inspect them

Wrap the SELECT in an INSERT with LIMIT 10, run it, and read the rows back from the hook table. Check that names are readable, ids match your order lines, and arrays hold no NULL element.
A NULL element inside category_path, additional_category_paths, discount_codes or items fails the nightly load for the whole table. Filter empty segments out before you insert.
4

Shape customers, orders and refunds

Repeat the last two steps for the other tables. Orders carry their lines in items, an ARRAY<STRUCT>. Build it with ARRAY_AGG(STRUCT(...)) over your order lines, grouped by order. Every amount excludes tax.
Amounts that include tax inflate gross sales in every report by the tax rate. Divide by 1 plus the rate before you insert.
5

Schedule the inserts

In the BigQuery console, save each INSERT as a scheduled query that runs daily at 00:00 UTC over the rows changed in the last 2 days. Remove the LIMIT. The 2-day window catches late changes. The same row twice is harmless.
6

Add rate cards

Optional. Insert one row per shipping and payment method with what the method costs you. Profit then includes shipping and payment cost for orders that carry no cost of their own.
7

Backfill history

Run each INSERT once without the date filter, product variants and customers first, then orders, then refunds. Oldest orders first when the history is large.

Columns

Every amount excludes tax. Every timestamp is UTC. Columns marked required are NOT NULL in the table.

eyk_ingest_orders

Each element of items is a STRUCT with these fields, in this order:

eyk_ingest_customers

eyk_ingest_product_variants

One row per sellable variant. A product without variants is one row with no parent_id.

eyk_ingest_refunds

Each element of items is a STRUCT with these fields, in this order:

eyk_ingest_shipping_methods and eyk_ingest_payment_methods

A rate card: what a shipping or payment method costs you, per method, from a date onward. Eyk applies it to orders that name the method and carry no shipping_cost or payment_cost of their own.

Full insert examples

Complete statements for the four main tables. Replace the project and dataset and the source tables.

Check it worked

Run these on your hook tables the morning after the first scheduled run. Then open the Custom BigQuery source in Eyk under Sources and read the Monitor tab: it lists orders, refunds, product variants and customers received per day. Data appears in reports the morning after Eyk’s night run.

Troubleshooting

The account that runs the scheduled query has no write access to the _import dataset, or the query runs in another location than the dataset. Ask your Eyk contact person if you need help with this step.
A required column received NULL. Common causes: a customer without email, a refund without order id, an order line without id or quantity.
One of the array columns holds a NULL. Filter with WHERE s IS NOT NULL AND TRIM(s) != '' inside the ARRAY(...) subquery.
Your INSERT names a column that does not exist in the table. Compare it with Columns.
Field order and types inside STRUCT(...) must match the table exactly, in the order listed under Columns. Name every field with AS.
Nothing to fix. Eyk keeps one version per id, the one with the latest updated_at.