Shopify merchants and developers rely on accurate analytics to make data‑driven decisions. The latest Merchant Changelog entry, “Improved shipping and duty data in Analytics,” upgrades the granularity and timeliness of shipping costs and duties across the platform. In this post we’ll unpack the change, identify who it impacts, and give you concrete steps to ensure your reports, dashboards, and custom code stay spot‑on.
What Changed: More Complete Shipping & Duty Data
Shopify now captures a fuller picture of every order’s shipping expenses and any applicable customs duties. The data feed into both native Shopify reports (like “Average profit margin by market” and “Profit margin by order”) and any custom analytics you’ve built using the Analytics API or the new Reports API. The key improvements are:
Who Is Affected: Merchants vs. Developers
Merchants – Store owners will see altered numbers in profit‑related reports. If you’ve set profit‑margin targets or use these metrics to drive advertising spend, expect a short adjustment period while the new data settles.
Developers – Anyone pulling shipping or duty fields via the GraphQL Analytics API, the REST Admin API, or the Reports API must verify that their queries reference the updated field names and data types. The schema itself hasn’t changed, but the values returned will be richer, which can affect downstream calculations, alerts, and UI components.
Impact on Reports & Profit Calculations
Because shipping and duty costs flow directly into profit calculations, you may notice:
These shifts are not errors; they reflect a more accurate cost basis. The change also means historic reports will no longer be directly comparable to post‑update data unless you apply a normalization factor.
Action Steps for Merchants
Implementation Tips for Developers
shippingLines.totalPriceSet and duty.amountSet, but the amountSet now includes carrier‑added components. Example query:graphql
query OrderAnalytics($ids: [ID!]!) {
orders(first: 100, query: $ids) {
edges {
node {
id
totalPriceSet {
shopMoney { amount currencyCode }
}
shippingLines {
totalPriceSet {
shopMoney { amount currencyCode }
}
}
duties {
amountSet {
shopMoney { amount currencyCode }
}
}
}
}
}
}
shippingLines.totalPriceSet only, now also subtract duties.amountSet to keep margins accurate.description field that it uses the post‑update schema. This helps future team members understand the context.Sample Code: Adjusting a Custom Profit Report
Below is a lightweight Node.js snippet that pulls orders, computes net profit, and stores the result in a temporary collection for a dashboard widget. The key addition is the duty subtraction:
js
const { GraphQLClient } = require('graphql-request');
const client = new GraphQLClient('https://your-store.myshopify.com/admin/api/2024-07/graphql.json', {
headers: { 'X-Shopify-Access-Token': process.env.SHOPIFY_TOKEN }
});
const QUERY = `
query ($ids: [ID!]) {
orders(first: 200, query: $ids) {
edges { node {
id
totalPriceSet { shopMoney { amount } }
shippingLines { totalPriceSet { shopMoney { amount } } }
duties { amountSet { shopMoney { amount } } }
} }
}
}`;
async function fetchOrders(ids) {
const data = await client.request(QUERY, { ids });
return data.orders.edges.map(e => e.node);
}
function calculateNetProfit(order) {
const revenue = parseFloat(order.totalPriceSet.shopMoney.amount);
const shipping = order.shippingLines.reduce((sum, s) => sum + parseFloat(s.totalPriceSet.shopMoney.amount), 0);
const duties = order.duties.reduce((sum, d) => sum + parseFloat(d.amountSet.shopMoney.amount), 0);
// Assume costOfGoods is stored elsewhere; using placeholder 0 for demo
const costOfGoods = 0;
return revenue - shipping - duties - costOfGoods;
}
(async () => {
const orders = await fetchOrders('created_at:>2024-09-01');
const profits = orders.map(o => ({ id: o.id, netProfit: calculateNetProfit(o) }));
console.log(profits);
})();
Integrate this logic into your analytics pipeline, and you’ll see profit margins that match the updated Shopify reports.
Conclusion & Next Steps
Shopify’s enhanced shipping and duty data brings greater transparency to the cost side of e‑commerce, empowering merchants to make smarter pricing, marketing, and inventory decisions. By reviewing the refreshed reports, updating any custom calculations, and testing your API integrations, you’ll avoid surprises and fully benefit from the new accuracy.
Ready to tighten your profit analysis? Dive into your Analytics dashboard today, update your custom queries, and share the insights with your finance team. If you hit any roadblocks, drop a comment below or reach out to a Shopify Expert – we’re here to help you turn data into growth.
