Attribution

See the campaign source and click id of every Shopify order

How to keep UTM tags and click ids (gclid, fbclid, ttclid) with every Shopify order, what each parameter means, and how order data improves attribution.

·7 min read·By the ROASaurus team

Key takeaways
  • UTM tags say which campaign a visit came from; click ids such as gclid, fbclid and ttclid tie the visit to one exact ad click.
  • Both live in the browser at first and disappear when nothing saves them: on a later visit, a blocked script or a payment page on another domain.
  • Saving them in the cart when the shopper lands carries them into the Shopify order, so every order keeps its source even when the pixel never fired.
  • With the source on the order you can audit single orders, credit campaigns on real purchases and send server events with the right click id to Meta, Google and TikTok.

To see the campaign source and click id of every Shopify order, save the UTM tags and the ad platform's click id when the shopper lands, write them to the cart, and let Shopify carry them into the order. Shopify then keeps them with the order as additional details, and a tracking tool can read them to credit the order and to send the purchase to Meta, Google Ads and TikTok with the right click id. Without that step, the values stay in the browser and are often gone by the time the order is placed.

This guide explains each parameter, why the data disappears, how to store it, what it lets you do, and how ROASaurus uses it today, including what waits for a Shopify permission.

The attribution parameters explained

Two kinds of values tell you where an order came from. UTM tags are labels you add to your own links. Click ids are added by the ad platform to each ad click.

ParameterSet byWhat it tells you
utm_sourceYou, in the ad or linkWhere the traffic came from: google, facebook, newsletter
utm_mediumYouThe type of channel: cpc, paid_social, email
utm_campaignYouThe campaign: spring_sale, bfcm
utm_content, utm_termYouThe ad variant, and the search term for search ads
utm_idYou or the platformA campaign id, for joining your data with the platform's
gclid, gbraid, wbraidGoogle Ads auto-taggingThe exact Google ad click; Google Ads needs it to credit an uploaded conversion
fbclid → _fbcMetaThe Meta ad click; stored as the _fbc cookie for the Conversions API
_fbpThe Meta pixelMeta's browser id, used for matching
ttclid, _ttpTikTokThe TikTok ad click and TikTok's browser id
msclkid, ScCid, epik, rdt_cid, twclidMicrosoft, Snapchat, Pinterest, Reddit, XThe click on each of those platforms
GA client idThe Google tagGA4's browser id, so a server-sent purchase can be joined to its session
Consent stateYour cookie bannerWhether the visitor allowed marketing tracking
UTM tags describe the campaign. Click ids identify one click, which is what an ad platform needs to credit a purchase.

The click id entry in the glossary has the short definition, and UTM parameters for Meta and TikTok shows how to tag your ads.

Why UTM and click id data disappear on Shopify

When a shopper lands from an ad, the UTM tags and the click id are in the address bar. From then on, they only survive if something saves them.

  • The shopper comes back later. The landing page with the tags was a visit days ago. Shopify records the visits before an order and their landing pages, but a click id that no tool kept on landing is easy to lose.
  • Scripts are blocked. Ad blockers, Safari's tracking prevention and iPhone privacy settings stop the scripts that would read and store the values. See what ad blockers do to your tracking.
  • Cookies expire. Safari limits cookies set by scripts to 7 days, or 24 hours after a visit from a link with a click id.
  • The checkout is sandboxed. Code in your theme does not run in Shopify's checkout, so it cannot add the values there.
  • Payment pages on another domain. A wallet or payment provider can break the chain between the visit and the confirmation page.

The symptoms are familiar: purchases under direct or unassigned in GA4 (see GA4 unassigned traffic), fewer purchases in Ads Manager than in Shopify, and revenue in GA4 that does not match Shopify (see GA4 vs Shopify revenue).

How to store the campaign source and click ids in Shopify orders

LandingRead the UTM tags and click ids from the address, first-party.
CartWrite them, or a visitor id that points to them, to hidden cart attributes.
OrderShopify copies the cart attributes into the order.
UseReports, audits and server events read them from the order.
The cart is the first place Shopify lets you store data for an anonymous shopper, and it travels with the order.
  1. Capture on landing

    A storefront script reads the UTM tags and click ids on every landing and keeps them first-party, on your own domain.

  2. Write cart attributes

    When the shopper adds to cart, the script writes the values to cart attributes. Attributes whose name starts with an underscore are hidden from the shopper at checkout.

  3. Let Shopify carry them

    Shopify copies the cart attributes into the order, where they appear with the order's additional details and in the order API.

  4. Respect consent

    Store click ids and visitor ids only when the visitor allowed marketing tracking, and record the consent state with them.

  5. Read them from the order

    Your attribution report and your server-side tracking read the values from the order, not from the browser.

Here is what the hidden attributes on an order can look like:

Example order attributes (placeholder values)
_tl         v_7f3a9c21e4
_tl_gclid   Cj0KCQiA…BwE
_tl_fbc     fb.1.1795600000000.IwAR2x…
_tl_fbp     fb.1.1795512000000.1834567890
_tl_ttclid  E.C.P.v3…
_tl_market  us

How the data helps you optimize marketing

  • Trace an order back to its source. When Ads Manager or GA4 misses a purchase, the order still shows which campaign and which click brought it.
  • Credit campaigns on real purchases. Count orders and revenue per campaign from your orders, not from what each platform claims.
  • Recover from tracking failures. A purchase GA4 put under direct, with a gclid on the order, was a Google Ads click.
  • Read refunds per campaign. If one campaign brings many refunded orders, its source on those orders shows it.
  • Help customer service. Knowing that a shopper came from a discount campaign or a specific ad explains their expectations.
  • Build your own reports. Export or filter orders by campaign, channel or click id without depending on a platform dashboard.

Does this work with Meta, Google Ads and TikTok?

Yes, and that is where the stored values matter most. Each platform credits a server-sent purchase better when it carries the platform's own click id:

PlatformValue from the orderWhat it improves
Metafbc and fbpConversions API purchases are tied to the ad click, which raises Event Match Quality
Google Adsgclid, gbraid or wbraidServer-sent conversions are credited to the exact click; hashed email helps when there is none
TikTokttclid and ttpEvents API purchases are tied to the click, also when the TikTok pixel was blocked on a phone
GA4The client idA Measurement Protocol purchase joins the session that carried the campaign
The order becomes the source of the server event, so the click id survives even when the browser never sent the purchase.

Server-side tracking on Shopify shows the full flow, and the ecommerce analytics guide covers the reports you can build on it.

How ROASaurus uses the order data today

On Shopify, the ROASaurus storefront script captures click ids and UTM tags first-party, through the app proxy on your own store domain. With marketing consent, it writes hidden cart attributes to every cart: the visitor id (_tl), the Meta, TikTok and Google click ids and browser ids, and the Shopify Market. The order arrives with them, and ROASaurus links it to every click and visit of that visitor. If the attributes are missing, it falls back to the thank-you page event, the hashed email, and the IP address and browser, and then to the click ids and UTMs in the landing page Shopify saved with the order.

Each order's page under Profit › Orders › Journeys shows the ad clicks before the purchase with their campaigns, the time to convert, how the order was matched (by cart attributes or a fallback), the credit each of the twelve attribution models gives each click, and a timeline of the journey. Profit › Orders › Profit per order filters orders by channel and UTM. The attribution report under Marketing › Channels & campaigns › Attribution adds it up per channel and campaign, with a lookback of 1 to 90 days or unlimited, 7 days by default. The same click ids go out with every server-side purchase, to Meta, Google Ads, TikTok and the other platforms you connect.

Setup

There is nothing to configure for the cart attributes: install the ROASaurus Shopify app and turn on its theme app embed, and every cart from a visitor with marketing consent gets them. To check, open a recent order's journey page and look at Matched by. The setup steps are in the Shopify setup guide, and the marketing attribution guide explains the models. Before a peak, run the BFCM tracking checklist, and check that your email tool gets the same data with Klaviyo tracking on Shopify.

Sources

  1. Shopify Dev Docs: Order object (custom attributes, customer journey summary)
  2. Shopify Help Center: Measuring marketing performance
  3. Google for Developers: Send offline conversion events to Google Ads (Data Manager API)
  4. Meta for Developers: ClickID and the fbp and fbc parameters

In ROASaurus

Keep reading

MarketingBFCM tracking checklist: can you trust your ad results?A Black Friday tracking checklist: test a real purchase, find duplicate conversions, choose which orders count, check consent and judge ads on profit.MarketingHow the Klaviyo Shopify integration tracks eventsHow Klaviyo collects Shopify data: order events, Checkout Started, onsite events, how it identifies visitors, where coverage ends and how to set it up.AnalyticsUnassigned traffic and "(not set)" in GA4What Unassigned and (not set) mean in GA4, the causes behind them on Shopify stores, how to find the affected traffic and what you can and cannot fix.

FAQ

Questions, answered

More answers in the FAQ and the help center.

Does Shopify store UTM parameters in orders?

Shopify records the visits before an order and their landing pages, which can contain UTM tags. A click id or UTM tag that no tool saved on landing can be lost, so most stores save them in cart attributes, which Shopify copies into the order.

What is the difference between a UTM tag and a click id?

A UTM tag is a label you add to your links to name the source, medium and campaign. A click id, such as gclid or fbclid, is added by the ad platform and identifies one exact ad click.

Where do I see cart attributes on a Shopify order?

Shopify copies cart attributes into the order, where they appear with the order's additional details and in the order API. Attributes whose name starts with an underscore are hidden from the shopper at checkout.

Why does GA4 show my Google Ads orders as direct?

Usually because the session that carried the campaign was lost: a blocked tag, an expired cookie or a payment page on another domain. A gclid stored on the order shows the purchase came from a Google ad.

Do I need consent to store click ids on the order?

In the EU, storing and reading click ids and visitor ids for advertising generally needs the visitor's consent. Save them only when the visitor allowed marketing tracking, and record the consent state.

Every sale, traced to the ad that earned it

Server-side tracking, profit and lifetime value in one app. Free plan, no credit card.