> For the complete documentation index, see [llms.txt](https://help.littledata.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.littledata.io/advanced/troubleshooting/troubleshooting-marketing-attribution-for-shopify.md).

# Troubleshooting marketing attribution for Shopify

Find out why some Shopify orders show up in GA4 as Direct or Unassigned, or with no source, and how to check that Littledata's tracking can link orders to the shopper's visit.

If many of your Shopify orders show up in Google Analytics as **Direct** or **Unassigned**, or you see events with no source, Littledata may not be linking those orders to the shopper's visit. This page explains why that happens and what to check on your store.

## Why some orders have no marketing source

To give an order a marketing source, Littledata needs to connect it to the shopper's earlier visit to your store. It does this with the IDs its script saves while the shopper browses, such as the GA4 client ID.

When those IDs aren't available, Littledata still sends the order, so your revenue and order totals stay complete. It gives the order a stand-in ID instead. In Segment, these IDs start with `default.littledata.`. Because the stand-in ID isn't linked to a visit, GA4 can't tell where the order came from.

Some orders will always look like this. For example:

* The shopper blocked tracking scripts or didn't give tracking consent.
* The shopper went straight to checkout, for example from a buy now button or a checkout link.
* The order wasn't placed on your online store, for example a POS order, draft order or subscription renewal.

A large or sudden rise in orders without a source usually means one of the problems below.

{% hint style="info" %}
For report-side fixes, such as UTM tags and custom channel groups, see [How to fix Unassigned traffic in GA4](/advanced/troubleshooting/fix-unassigned-traffic-ga4.md).
{% endhint %}

## Check that Littledata's script is on every page

Littledata's script must load on every page of your store. It's added by the Littledata app embed in your theme.

{% stepper %}
{% step %}

#### Open your theme's app embeds

In Shopify admin, go to **Online Store** > **Themes**. Next to your live theme, click **Customize**, then click the **App embeds** icon in the left sidebar.
{% endstep %}

{% step %}

#### Check the Littledata embed is on

Make sure the Littledata embed is switched on, then click **Save** if you changed it.
{% endstep %}

{% step %}

#### Confirm it on your store

Open any page of your store in Chrome, right-click and choose **Inspect**, then open the **Console** tab. Type `LittledataLayer` and press **Enter**. If you see an object, the script is loaded. If you see an error saying it's not defined, the script isn't running on that page.
{% endstep %}
{% endstepper %}

Check a few different page types, such as the home page, a collection, a product page and the cart. Pages built by other apps, such as landing page builders, sometimes don't load app embeds.

## Check that Littledata's IDs are saved to the cart

Littledata's script saves the shopper's IDs to the Shopify cart, in a cart attribute called `__ld_attr`. When the order is placed, Littledata reads them back to link the order to the visit. If another app removes or overwrites the cart's attributes, orders lose their source.

{% stepper %}
{% step %}

#### Browse your store

Open your store, view a couple of pages and add a product to the cart.
{% endstep %}

{% step %}

#### Open the console

Right-click on the page, choose **Inspect**, then open the **Console** tab.
{% endstep %}

{% step %}

#### Paste this snippet

Paste the snippet below and press **Enter**.

```javascript
fetch('/cart.js')
  .then((response) => response.json())
  .then((cart) => {
    const ids = cart.attributes['__ld_attr'];
    console.log(ids ? JSON.parse(atob(ids)) : 'Littledata IDs are missing from the cart');
  });
```

{% endstep %}

{% step %}

#### Read the result

If the IDs are saved, you'll see an object with an entry for each connected destination, such as `googleAnalytics4`. If you see **Littledata IDs are missing from the cart**, something is stopping Littledata from saving them.
{% endstep %}
{% endstepper %}

If the IDs are missing, look for apps that change the cart:

* **Cart drawers and upsell apps** that rebuild the cart can clear its attributes.
* **Custom buy buttons or checkout links** that create a new cart skip the IDs saved on the old one.
* **Headless storefronts** need extra setup. See [Headless Shopify](/sources/shopify/headless-shopify.md).

To find the app, run the snippet again after each step of your shopping flow, such as after opening the cart drawer. The step where the IDs disappear points to the app that's removing them. If you can't find the cause, email <help@littledata.io> with the steps you took.

## Add the Littledata Pixel

The [Littledata Pixel](/sources/shopify/littledata-pixel.md) runs in Shopify's customer events, so it tracks the checkout and more of the shopper's journey. It makes tracking more reliable for every store, and headless storefronts need it.

## Check your consent settings

If **Consent mode** is on for a destination, Littledata respects each shopper's choice in Shopify's customer privacy settings. Orders from shoppers who decline tracking still count, but without a marketing source. If your consent banner makes declining the easy choice, expect more orders without a source. See [How consent banner design affects your GA4 data](/advanced/troubleshooting/consent-banner-design-ga4.md).

## Related articles

* [How to fix Unassigned traffic in GA4](/advanced/troubleshooting/fix-unassigned-traffic-ga4.md)
* [Shopify vs Google Analytics data discrepancies](/advanced/troubleshooting/shopify-vs-google-analytics-data-discrepancies.md)
* [Littledata's app embed](/advanced/developer/littledata-app-embed-how-it-works.md)
* [How it works: Shopify to Google Analytics](/integrations/shopify-to-google-analytics/how-it-works-shopify-to-ga4.md)
