GTM and Google Analytics data layer for Shopify

Updated on 2023-10-18
note:

Littledata maintains a GTM template in the Tag Manager Template Gallery which you can use to more easily access ecommerce data in other GTM tags

Littledata’s tracking script for Shopify stores adds lots of detailed events which you can use to build funnels or trigger other marketing tags in Google Tag Manager (GTM).

Our script uses the naming conventions set by Google for gtag.

Definitions

  • Littledata Layer: the field name in the 'LittledataLayer' window-scope variable which you can access as a JavaScript variable in GTM.
  • GTM event: the name of the event field pushed to the GTM dataLayer, which can be used for a custom trigger in GTM.
  • GTM variables: the other properties accessible at the time of this event as a user-defined Data Layer Variable in GTM.
  • GA category: the name of the Event Category which you can report on in Google Analytics
  • GA action: the name of the Event Action which you can report on in Google Analytics
  • GA label: the possible values of the Event Label in Google Analytics
tip:

Littledata's script sends all events to Google Analytics by default. If you wish to disable the pre-checkout GA events, and send them yourself via GTM, you can set the disableClientSideEvents setting to true in the Littledata layer.

All pages

Pageview

GTM event: pageview

GTM variables: page_title, page_location

GA: page view (not an event)

Pageviews are only sent when the page is actually rendered for the user. So if the page is loaded in the background, on a hidden tab, or the user closes the browser tag before the page renders a pageview will not be triggered.

If a customer is logged in

GTM event: gtm.js

Littledata Layer: customer

{
  ...
  customer: {
    id: '1234', // same as Shopify customer ID
    name: 'John Smith',
    email: 'john@smith.com',
    phone: '+442083508061'
  }
}

GA Event: None (GA cannot accept personal data)

Product listing page

Viewing a product in the list

GTM event: view_item_list

GTM variables: ecommerce.impressions (i.e. products, see Product Item below),

GA category: Shopify (Littledata)

GA action: view_item_list

View item events are only sent when more than 80% of the product image becomes visible on the user's screen. So as the user scrolls down the page, events will be sent in batches containing the items in the row that becomes visible.

Clicking on a product in the list

GTM event: select_content

GTM variables: ecommerce.click.products

GA category: Shopify (Littledata)

GA action: select_item

Not all click events will have time to trigger tags before the page redirects. We don't take the risk of delaying redirects to wait for tags to fire.

Product details page

The product item

Each product contains the following fields:

  • id (either the product ID or SKU)
  • name
  • price
  • brand
  • category
  • handle (for product details and listing events only)
  • variant
  • shopify_product_id
  • shopify_variant_id
  • compare_at_price
  • image_url

When product page loads

GTM event: view_item

GTM variables: ecommerce.details.products (a single product),

GA category: Shopify (Littledata)

GA action: view_item

Clicks on product image

GTM event: product_image_click

GA category: Shopify (Littledata)

GA action: Product image click

GA label: Name of the product image

Social share

GTM event: share_product

GA category: Shopify (Littledata)

GA action: Social share

GA label: Name of the social network

Thank you page

On the thank you page, after the order is processed, we send an event you can use to trigger other tags. The transaction event for GA is sent from Littledata's servers - see below.

GTM event: transaction

GA category: Shopify (Littledata)

GA action: Checkout

GA label: Thank you page viewed

GTM event properties:

  • transactionId (Shopify order name displayed on the page, not Shopify's internal order number)
  • coupon (string)
  • currency (string)
  • discount (string)
  • email (string)
  • transactionProducts (see Product Detail above, plus quantity but without category)
  • transactionShipping (string)
  • transactionTax (string)
  • transactionTotal (string)
  • ecommerce.purchase (Google Analytics Enhanced Ecommerce format)
note:

All events from add to cart onwards are tracked only server-side direct from Shopify. This ensures accuracy and speed for GA tracking, but means there is no GTM event on which to trigger your other tags.

Add (and remove) from cart

GA category: Shopify (Littledata)

GA action: add_to_cart or remove_from_cart

Checkout steps

GA category: Shopify (Littledata)

GA action: begin_checkout, shipping_info_entered or payment_info_(depending on the checkout step)

GA label: Contact information or Shipping information or Payment method

GA value: Total price

Order completed (including recurring orders)

GA category: Shopify (Littledata)

GA action: Purchase

GA label: The Shopify order Name

GA value: Total price

Order affiliation

For advanced segmentation based on order affiliation we send an additional event upon order completion.

GA category: Order affiliation (Littledata)

GA action: The Shopify order Name

GA label: Order affiliation

GA value: Total price

Order refunded

GA category: Shopify (Littledata)

GA action: Refund

GA label: The Shopify order Name

Customer Created

GA category: Shopify (Littledata)

GA action: Customer created

GA label: No marketing/single_opt_in