Ecommerce & Billing · Send via webhook

Shopify integration

Record paid Shopify orders, refunds and cancellations by webhook, and tie each order to the visit that brought the shopper.

No credit card required · one script tag

Record paid Shopify orders in SourceTrack, and see which ad, search or referral brought each shopper who bought.

Shopify sends each order to SourceTrack by webhook, signed by your store. A short theme snippet saves the SourceTrack visitor id on the cart, so the order can be tied back to the visit that earned it.

What SourceTrack records

  • Paid orders: the order total in your shop currency, recorded before tax where Shopify reports the tax. Shipping and discounts stay as Shopify has them.
  • Order details: the line items (product, variant, SKU, quantity, price and line discount), discount codes, and the shipping, subtotal and tax amounts.
  • Refunds: the money actually refunded, as a negative amount against the original order. A refund whose payment is pending or failed is not counted.
  • Cancellations: an order cancelled after it was recorded is reversed, less anything already refunded.
  • Storefront shopping steps: with the tracker on your theme, product views, cart views and add-to-cart clicks.

What SourceTrack does not do

  • It does not record unpaid orders. With the orders/create webhook, only orders that are already paid count.
  • It does not record Shopify test orders, for example ones placed with the Bogus Gateway.
  • It does not follow a visitor through Shopify checkout on its own. Without the cart snippet, an order can only be credited from the UTM tags Shopify saved on the order’s landing page, and otherwise shows as unattributed.
  • It does not send an order to any ad platform when the shopper said no to marketing in Shopify’s cookie banner.

Step-by-step setup

Step 1: Connect your store

In SourceTrack, open Integrations → Shopify webhook recipe and click Connect Store (OAuth). This registers SourceTrack’s order, refund and cancellation webhooks and a web pixel in your store. If the connect reports that the pixel or webhooks could not be registered, follow the manual steps in the Shopify setup guide instead.

Step 2: Add the tracker and the cart snippet to your theme

  1. In Shopify Admin, go to Online Store → Themes, open the action menu on your current theme and choose Edit code.
  2. Open layout/theme.liquid and paste the SourceTrack tracking script just before </head>.
  3. Paste the cart-attribute snippet from the Shopify setup guide just before </body>. It saves the visitor id (st_aid) on the cart, along with the shopper’s consent choice and, only while that choice allows marketing, their ad click ids.
  4. Save the file.

Step 3: If you set up webhooks by hand

Skip this if Connect Store registered the webhooks.

  1. In Shopify Admin, go to Settings → Notifications → Webhooks and create a webhook for orders/paid, in JSON, pointing at https://api.srctk.com/api/webhooks/shopify/YOUR_SITE_KEY.
  2. Add webhooks for refunds/create and orders/cancelled to the same URL, so refunds and cancellations net out.
  3. Copy the Shopify signing secret shown with your webhooks and paste it into SourceTrack under Integrations → Shopify webhook recipe.

How it works under the hood

Shopify signs each webhook. SourceTrack checks the signature against your store before it reads the order, and refuses one that does not match with a 400 error.

For a paid order, SourceTrack reads the visitor id from the st_aid cart attribute and credits the order to that visitor’s journey. With no visitor id, it reads the UTM tags on the order’s landing page and referring site, if any. If Shopify sends the same order more than once, it is recorded once.

A refund is counted from Shopify’s successful refund transactions, not from the item prices on the refund, and it inherits the original order’s visitor so it nets against the same source.

Sending orders to ad platforms (beta)

On a paid plan with Meta, Google Ads or another ad platform connected, a paid Shopify order can also be sent server-side to those platforms. This is in beta. It follows the shopper’s choice in Shopify’s cookie banner: when the shopper says no to marketing, the order is sent to none of your ad platforms.

Test it end to end

  1. Visit your store through a link with UTM tags, for example ?utm_source=test&utm_medium=email&utm_campaign=shopify-check.
  2. Add a product to the cart and complete a real, low-value order. Shopify test orders are not recorded.
  3. In Shopify Admin, check that the webhook delivery succeeded.
  4. In SourceTrack, check that the order appears with the test source.
  5. Refund the order in Shopify and check that the refund nets it out.

Common problems and fixes

  • Orders show as unattributed. The cart snippet is missing or was changed. Keep the attribute name st_aid exactly as written, and check that the tracker runs on your storefront.
  • A test order did not appear. Shopify test orders are ignored by design. Use a real, low-value order.
  • Refunds do not net out. If you set up webhooks by hand, add the refunds/create and orders/cancelled webhooks.
  • Webhooks fail with a 400 error. The signing secret saved in SourceTrack does not match your store. Copy it again from Shopify and save it.

Frequently Asked Questions

Do I have to edit my Shopify theme?

For attribution, yes. Connect Store records orders without a theme edit, but the cart snippet in theme.liquid is what ties an order back to the visit that brought the shopper.

How are refunds handled?

A refund is recorded as a negative amount against the original order, using the money Shopify actually refunded, so revenue by source is net of refunds. A cancelled order is reversed too.

Why did my test order not show up?

Orders that Shopify marks as test orders are ignored, so they never count as revenue. Use a real, low-value order and refund it afterwards.