Littledata's tracking script for Shopify stores.
This code is used by two Littledata apps:
The latest minified versions of these scripts are hosted on a CDN:
These scripts rely on the
LittledataLayer window-scope variable generated by a snippet in the Shopify store theme, and imported into the Store's active layout.
The following fields of the
LittledataLayer object allow for configuration of tracking features:
To enable cross-domain tracking on pages that your Shopify store links to (destination domains) you can add an extra array of domains to the data layer. You do not need to add domains here which only send traffic to your Shopify store (source domains) - by default this script will look for the linker URL parameters.
You will also need to enable the Google Analytics linker on those source or destination domains.
Add the Google Ads (AdWords) conversion IDs that you configured with Ads. This accepts an array of strings. Our script will automatically add this to
['AW-11111111', 'AW-22222222'] (array)
This is where to add the Google Optimize container ID that you want to configure with gtag. Our script will automatically add this to
This field to instructs the gtag library to mask the last 3 numbers of the user's IP address, to support greater user privacy at the expense of some geo-location accuracy.
By default our tracking code briefly interrupts a click on a product in a product list, in order to send the tracking event before the page reloads. If this is interfering with other apps or scripts you can turn off product list click tracking.
By default we track clicks on product images and social share buttons on the product details page. If this doesn't work with your theme you can opt out by setting this field to
Our app generates a branded message in the site console log. You can disable this.
For some themes, where the URL changes (e.g. a new variant) without a new page load our script will track a new page view. Change this setting to
true to disable a new page view on
history.replaceState() via browser History API
cookiesToTrack (Segment only)
Grab the values from an array of named cookies and pass them as traits on Segment identify calls.
If you wish to direct the Measurement Protocol hits to a custom collection endpoint of your choosing, add it here. NOTE: this will block the sending of hits to Google Analytics.