Since WooCommerce 8.5, an order that came from a tagged link keeps its UTM campaign, right in your store’s MySQL database. Let Claude or ChatGPT read it through a MySQL MCP server, next to your Facebook Ads or Google Ads account, and you get order totals against spend, by campaign, from one question.
WooCommerce’s order attribution stores utm_campaign, utm_source and utm_medium with each order. They sit in the wp_wc_orders_meta table, under keys like _wc_order_attribution_utm_campaign, next to the orders in wp_wc_orders. Your ad account knows what each campaign cost. Neither one alone tells a client what each campaign brought in for what it cost.
The two only line up when utm_campaign holds the campaign’s name. In Meta Ads, add utm_campaign={{campaign.name}} to each ad’s URL parameters. Google Ads auto-tagging doesn’t pass the name, and Google only offers {campaignid}, not the name, so type the name into each campaign’s final URL suffix. Orders placed before 8.5, or with attribution turned off, have no campaign.
Start each question with “Using SyncWith” and name the view:
This is your store’s own count, by the campaign each visit carried, so it won’t match the purchases or ROAS in Ads Manager. The view counts completed and processing orders, and its totals are before refunds, which WooCommerce keeps as separate rows.
First, ask your host whether your store’s database accepts connections from outside. If it does, send the SQL below to whoever runs the database. It needs WooCommerce’s own order tables, the default for new stores since 8.2. Change shop to your database’s name and wp_ to your table prefix.
-- 1. One view: paid orders and the campaign each came from
CREATE VIEW shop.ai_orders AS
SELECT o.id AS order_id,
o.date_created_gmt,
o.status,
o.currency,
o.total_amount,
c.meta_value AS utm_campaign,
s.meta_value AS utm_source
FROM shop.wp_wc_orders o
LEFT JOIN shop.wp_wc_orders_meta c
ON c.order_id = o.id
AND c.meta_key = '_wc_order_attribution_utm_campaign'
LEFT JOIN shop.wp_wc_orders_meta s
ON s.order_id = o.id
AND s.meta_key = '_wc_order_attribution_utm_source'
WHERE o.type = 'shop_order'
AND o.status IN ('wc-completed', 'wc-processing');
-- 2. A login for each SyncWith address, capped at 500 queries an hour
CREATE USER 'ai_reader'@'3.227.95.35' IDENTIFIED BY 'change-me'
WITH MAX_QUERIES_PER_HOUR 500;
CREATE USER 'ai_reader'@'34.199.138.158' IDENTIFIED BY 'change-me'
WITH MAX_QUERIES_PER_HOUR 500;
-- 3. Both can read the view and nothing else
GRANT SELECT ON shop.ai_orders
TO 'ai_reader'@'3.227.95.35', 'ai_reader'@'34.199.138.158';ai_reader sees only what the view shows: no email, IP address, browser or customer note. Whoever creates it needs the CREATE VIEW privilege and SELECT on the two tables.SELECT ... INTO OUTFILE, a SELECT that writes a file. This login can’t run it: it needs the FILE privilege, and no grant on a single view can give FILE.Claude.ai and ChatGPT on the web only reach remote servers, and ours is one, so there’s nothing to install. Add https://mcp.syncwith.com/mcp as a custom connector (steps for Claude, on any plan, and ChatGPT, on Business, Enterprise or Edu). Allow 3.227.95.35 and 34.199.138.158 through your firewall, then ask it to connect MySQL and paste the connection string for ai_reader into the form it links. To check, ask “Using SyncWith, what columns can you see in ai_orders?” If you’d rather run a MySQL MCP server on your own computer in Claude Desktop or Cursor, the view suits it too.
There’s no separate charge for the MCP server today. Each database query uses one refresh from your SyncWith plan, and the free Hobby plan includes 35 refreshes a month. Listing tables doesn’t use any.
Want these numbers in a sheet that updates itself? See MySQL to Google Sheets. Every tool the server has is in the SyncWith MCP docs.