
Shopify UTM tracking answers a plain question: which campaign sent the shopper who bought? This guide is for store owners and marketers running ads, email or influencer posts who want that answer on the order itself. You will see what Shopify already stores, where it goes missing, and how to capture UTM parameters and click IDs yourself, with a naming template and checklist at the end.
What UTM parameters are
A UTM tag is text added to the end of a link, like ?utm_source=google&utm_medium=cpc&utm_campaign=spring_sale. When someone clicks, your store can read those values. There are five standard parts: source, medium, campaign, content and term, and Shopify’s UTMParameters object holds exactly those five.
The tags are only as good as the discipline behind them. “Facebook”, “facebook” and “fb” show up as three different sources in every report.
Does Shopify track UTM parameters?
Partly, yes. Shopify attaches a customer journey summary to orders. In the Admin GraphQL API that is CustomerJourneySummary, reached through Order.customerJourneySummary. The reference lists these fields:
firstVisitandlastVisit: the first session going into the shop, and the last one before the order.daysToConversion: days from the first session to the order, with a 30-day attribution window described for gaps between orders.moments: events leading up to the order, such as sessions.ready: whether the sessions have been attributed yet. Check it before trusting the data, because attribution can lag behind the order.
Each visit is a CustomerVisit with landingPage, referrerUrl, utmParameters, source (platform, email, direct, domain, QR code or unknown) and occurredAt.
One trap for developers: the Order reference marks older fields such as landingPageUrl, referrerUrl and customerJourney as deprecated. Build on customerJourneySummary, and recheck the API version you use. sourceName still tells you the sales channel (web, POS and so on). In the admin, acquisition and marketing reports use the same attributed visit data, so start there if you do not need code.
Where Shopify’s attribution falls short
| Gap | What it looks like |
|---|---|
| Visits Shopify could not see | Visitors who decline tracking or block it have no usable journey |
| Untagged links | Show as direct or as a bare referrer |
| Click IDs | Platform click IDs such as gclid or fbclid are not an obvious column in standard reports |
| Stripped parameters | Link shorteners, in-app browsers and redirects can drop the query string |
| Cross-device buying | A phone click and a laptop purchase look like two people |
| Timing | The journey summary may not be ready when the order arrives |
Why do my UTMs show as direct?
Usually one of four things: the link was never tagged, a redirect or shortener removed the tags, the click came from an app’s built-in browser, or the visitor opted out of tracking. Test your own links on a phone, from the real channel, and look at what arrives. Do this for each campaign type before launch.
Capturing UTMs and click IDs yourself
If you want a copy on every order, for a sheet, a CRM or a warehouse, the usual route is to save the values in the cart and let them travel to the order.
- Read the landing URL. On the first page view, read the
utm_parameters and any click IDs (gclid,fbclid,ttclid). - Store them first-party. Keep them in the browser, in a cookie or local storage, so they survive navigation. Keep the first touch and the latest touch separately.
- Write them to the cart. Shopify’s Cart Ajax API accepts an
attributesobject on/cart/update.js. Cart attributes carry through checkout to the order. - Make them private if customers should not see them. Per the docs, a name starting with a double underscore (
__) is hidden at checkout and excluded from Liquid and the Ajax API, but still visible on the order details page in the admin. - Read them back. Orders expose
customAttributesin the Admin API.
The cart update looks like this:
// Run after you have read and stored the UTM values.
// Names starting with "__" are private attributes (see Shopify's Ajax API docs).
fetch(window.Shopify.routes.root + 'cart/update.js', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
attributes: {
'__utm_source': 'google',
'__utm_medium': 'cpc',
'__utm_campaign': 'spring_sale'
}
})
});
Shopify’s docs do not say whether update.js replaces or merges attributes already on the cart. Test on a development store, and send the full set each time until you know.
Where does this code live? In the theme, or in an app embed. A sandboxed pixel cannot modify the page, so a custom pixel is the wrong place; our Shopify tracking setup guide explains the sandbox. Keep the script tiny, because every script costs speed (see third-party app bloat).
To read Shopify’s own record and your custom values together:
# Replace the ID. Check the API version and your app's order read scopes first.
query OrderAttribution {
order(id: "gid://shopify/Order/1234567890") {
name
customAttributes { key value }
customerJourneySummary {
ready
daysToConversion
firstVisit { landingPage referrerUrl source utmParameters { source medium campaign content term } }
lastVisit { landingPage referrerUrl source utmParameters { source medium campaign content term } }
}
}
}
If this feeds an integration, the pattern is covered in building a Shopify custom app with the Admin API and webhooks.
UTM naming template
Write this in a shared sheet before the first campaign goes out.
| Parameter | Rule | Good | Bad |
|---|---|---|---|
utm_source | The platform, lowercase | google, meta, tiktok, klaviyo | Google Ads, FB |
utm_medium | The channel type | cpc, paid_social, email, influencer | ads, social |
utm_campaign | Goal plus period, underscores | spring_sale_2027, welcome_flow | Spring Sale!! |
utm_content | Creative or link position | video_a, hero_banner | ad1 with no key |
utm_term | Paid search keyword | running_shoes | blank, or with spaces |
Lowercase only, no spaces, and never an email address or name in a UTM. Where an ad platform adds its own auto-tagging, such as Google’s gclid, keep it alongside your tags.
A simple attribution view
You do not need a warehouse to get started. Export orders weekly, or pull them through the API, with the journey fields and your custom attributes. Put these columns in a sheet: order, date, revenue, first-touch source, medium and campaign, last-touch source, medium and campaign, landing page, and whether a click ID was present. Pivot revenue by campaign twice, once by first touch and once by last touch. Then set the numbers beside what each ad platform claims and write down the gap per channel. A gap that stays steady is fine. One that suddenly widens means something broke.
State the model on the sheet. The same orders tell a different story under first touch than last touch.
Privacy and consent
UTM values describe a campaign and are not usually personal data. Attaching them to an identifiable order, and storing click IDs in cookies, can still fall under cookie and privacy rules. Respect your consent banner, store the minimum, and say what you store in your privacy policy. GDPR, ePrivacy and CCPA-style rules vary by market, and this is not legal advice.
The honest limits
No attribution model tells you what caused a sale. Last touch gives too much credit to the final click, often brand search or an email. First touch gives too much to discovery. People research on one device and buy on another. Use attribution to compare campaigns over weeks, not to settle a dispute about one order. When a budget decision is large, the better evidence is an experiment, such as a holdout or lift test run by the ad platform. If you also want server-side data, see server-side tracking for Shopify.
Checklist
- UTM naming sheet agreed
- Every paid, email and social link tagged before it goes live
- Auto-tagging (click IDs) enabled on ad platforms
- Capture script added to the theme and tested on mobile
- Values visible on a test order in the admin
- Consent banner controls storage of click IDs
- Weekly sheet built, with the model stated
- Gaps against ad platforms recorded
Frequently Asked Questions
What is the difference between cart attributes and the cart note?
Cart attributes are named fields you add to a cart, and they carry to the order. The cart note is a single free-text box for the customer. Use attributes for tracking data.
Can I see UTMs in the Shopify admin?
Shopify’s acquisition and marketing reports use attributed visit data, and private cart attributes appear on the order details page. What you see depends on your plan and reports.
Should I use first-touch or last-touch attribution?
Keep both. First touch shows what brings people in, last touch shows what closes. Treat them as two views, not a verdict.
Do I need an app for Shopify UTM tracking?
Not always. Shopify’s own reports cover the basics. Apps help when you need click IDs on every order or a combined report, but check what they store and whether they respect consent.
Why is Shopify’s data different from my ad platform’s?
Platforms count their own clicks and views with their own windows, and Shopify counts visits it saw. They will rarely match exactly.
Conclusion
Shopify already records a useful journey for many orders. Disciplined UTM naming plus your own first-party capture makes Shopify UTM tracking easier to report on and easier to move into other tools. Keep the capture small, respect consent, and judge campaigns by trends. If you would like help with this, CYPHEX can plan and deliver it for you, with one project lead as your contact. You can also see our Shopify services.
Stock photography provided by Pexels under the Pexels License.
