Troubleshooting marketing attribution for Shopify

Updated on 2021-12-29

If your orders from Shopify in Google Analytics are attributed to the Direct channel, or you are seeing strange clusters of events of 'orphan' events, there are a few steps of Littledata's tracking that could be going wrong.

The add to cart, checkout steps, orders and Recharge subscription events are sent from Littledata's cloud servers in the AWS East region  - so you may see sessions and conversions from Clifton, New Jersey or Ashburn, Virginia if the link between the end users' browser session and our server is broken.

If you're using our Segment source, this problem will manifest itself as events coming from Boardman, Oregon - where Segment's servers relay our events to Google Analytics.

Known limitations of user tracking

In the following situations we have no way of linking server-side events (including orders) to the preceding website visit:

  • When the order is from a source other than your own website; for example, one processed on Amazon Marketplace. You can see this by adding the custom dimension `Payment gateway` to the sales reports
  • When the order is a recurring charge from a subscription which was set up before Littledata was installed (i.e. Littledata never tracked the session where the customer subscribed)
  • When the user (or the user's browser) has blocked tracking scripts, so no events are sent from the user's browser

In these cases you will see in Google Analytics:

  • The channel is Direct
  • The landing page for the session is (not set)
  • All dimensions set form the web browser (version, screen size etc) are (not set)
  • In the User Explorer report, the client ID starts with default.littledata

In Segment you will see that the anonymous ID starts with default.littledata

What if the customer ID is known for these orphan events?

For orphan events about known customers (e.g. a recurring order or refund), we use the Shopify customer ID as the userId field. We also create a unique client ID / anonymous ID for each user (starting with default.littledata). This identifier is persisted across all future events for that same user.

So any events linked to the same userId will also share this same client ID. e.g. you can see all the recurring orders that user made, but not the original marketing source of those orders.

Making use of unlinked events

Littledata still sends events which can't be linked back to the customer, so you can measure accurate volumes of user activity (e.g. total revenue). Every web analytics system has similar limitations to the above - but our servers ensure that even when customers block scripts (does not want to be tracked), you can still anonymously include their orders in the total.

Issues to investigate

The following issues can all lead to an abnormal level (more than 10%) of events not linked to the pre-checkout web session.

Missing LittledataLayer

All pages need Littledata's snippet included in the Shopify theme - which populates the LittledataLayer with ecommerce data on that page. You can include that snippet manually or login to Littledata to update the snippet across your store.

tip:

Go to the JavaScript console of the page in question and type in LittledataLayer into the console to see if it is defined.

check datalayer version

Outdated data layer version

If your store is not using the latest Littledata data layer, it may have been reverted when the Shopify theme was updated. You can update that snippet manually or login to Littledata to update the snippet across your store. The current version at the time of writing was v8.2

tip:

Go to the JavaScript console of the page in question and type in LittledataLayer to see the version.

Littledata’s script stores the client ID from Google Analytics’s cookie within the Shopify cart. If this is not set correctly, then the data collection will fail.

tip:

Request the current cart from Shopify and check that attributes field contains google-clientID (or segment-clientID)

You can log the cart contents by pasting this snippet into the browser console:

var request = new XMLHttpRequest();
request.open("GET", "/cart.js", true);
request.onload = () => {
  var data = JSON.parse(request.responseText);
  data.attributes["google-clientID"] || data.attributes["segment-clientID"]
    ? console.log(data.attributes)
    : console.log("Client ID attribute missing");
};
request.send();

Client ID stored in cart attributes

Further checks for Recharge checkout

Recharge stores need to check further steps.

Shopify domain not linking with Recharge checkout

If the Google Analytics cookie on the Recharge checkout domain is not the same as on the preceding Shopify store page, the user journey will be fragmented. Please check you have the Google Analytics integration activated for Recharge, and check for any console errors on the Recharge checkout.

Littledata integration not activated

Littledata needs permission to add this cookie tracking to the Recharge order notes. Go to Recharge integrations page to enable Littledata.