### Example context object JSON Source: https://help.littledata.io/event-editor/glossary A complete JSON example of the context object, showing all documented attributes with example values. Use this as a reference for the structure and data types of the context object. ```json { "campaign.utm_campaign": "spring_sale", "campaign.utm_content": "ad_variant_a", "campaign.utm_id": "5821934567", "campaign.utm_medium": "cpc", "campaign.utm_source": "google", "campaign.utm_term": "blue tshirt", "client_hints.architecture": "x86", "client_hints.bitness": "64", "client_hints.device_type": "mobile", "client_hints.mobile": true, "client_hints.model": "iPhone15,2", "client_hints.platform": "macOS", "client_hints.platform_version": "14.0.1", "client_hints.vendor": "Acme", "client_hints.wow_64": true, "country": "US", "ipv4": "192.0.2.42", "ipv6": "2001:db8::1", "language": "en", "littledata_id": "5821934567", "locale": "en-US", "page.path": "/products/blue-tshirt", "page.referrer": "https://example.com", "page.search": "?utm_source=google", "page.title": "Blue T-shirt", "page.url": "https://example.com", "screen.density": "2", "screen.height": "1080", "screen.width": "1920", "shopify_y": "5821934567", "timezone": "America/New_York", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36", "consent.analytics": true, "consent.marketing": true, "consent.preferences": true, "consent.sale_of_data": "denied" } ``` -------------------------------- ### products object JSON example Source: https://help.littledata.io/event-editor/glossary Example of the products object as a JSON object with fields for product details, pricing, discounts, images, variants, and metafields. ```json { "body_html": "
Soft cotton tee
", "category": "Apparel", "collections": [ "Summer", "Bestsellers" ], "compare_at_price.presentment": 19.99, "compare_at_price.shop": 19.99, "currency.conversion_rate": 1, "currency.presentment": "USD", "currency.shop": "USD", "discounted_price.presentment": 19.99, "discounted_price.shop": 19.99, "discounts.amount.presentment": 19.99, "discounts.amount.shop": 19.99, "discounts.title": "Summer sale", "gift_card": true, "grams": 1, "handle": "blue-tshirt", "image_url": "https://example.com", "images.alt": "Blue T-shirt", "images.height": 1080, "images.id": "5821934567", "images.position": 1, "images.product_id": "5821934567", "images.src": "https://example.com", "images.thumb_src": "https://example.com", "images.variant_ids": [ "5821934567" ], "images.width": 1920, "line_price.presentment": 19.99, "line_price.shop": 19.99, "name": "Blue T-shirt / Medium", "options.id": "5821934567", "options.name": "Size", "options.position": 1, "options.product_id": "5821934567", "options.values": [ "S", "M", "L" ], "price.presentment": 19.99, "price.shop": 19.99, "product_id": "5821934567", "product_identifier": "SKU-001", "product_type": "Apparel", "product_url": "https://example.com", "profit_margin_applied": 0.4, "profit_value.presentment": 19.99, "profit_value.shop": 19.99, "properties": { "engraving": "Happy Birthday" }, "quantity": 1, "sku": "SKU-001", "tags": [ "new", "summer" ], "taxable": true, "title": "Blue T-shirt", "total_discounts.presentment": 19.99, "total_discounts.shop": 19.99, "variant_id": "5821934567", "variant_options": [ "Size: M", "Colour: Blue" ], "variant_requires_shipping": true, "variant_title": "Medium", "vendor": "Acme", "destination_location_id": "5821934567", "metafields": { "custom.material": "cotton" }, "origin_location_id": "5821934567", "rank": 1, "tax.presentment": 19.99, "tax.shop": 19.99, "tax_line.position": 1, "tax_line.price": 19.99, "tax_line.rate": 0.2, "tax_line.title": "VAT", "unit_price_measurement.measured_type": "VOLUME", "unit_price_measurement.quantity_unit": "ml", "unit_price_measurement.quantity_value": 500, "unit_price_measurement.reference_unit": "l", "unit_price_measurement.reference_value": 1 } ``` -------------------------------- ### The shop object example Source: https://help.littledata.io/event-editor/glossary Example JSON object showing the shop object attributes. ```json { "country": "US", "currency": "USD", "domain": "https://example.com", "shopify_domain": "example.myshopify.com", "title": "Blue T-shirt" } ``` -------------------------------- ### The market object example Source: https://help.littledata.io/event-editor/glossary Example JSON object showing the market object attributes. ```json { "handle": "blue-tshirt", "id": "5821934567" } ``` -------------------------------- ### The money object example Source: https://help.littledata.io/event-editor/glossary Example JSON object showing the money object attributes with presentment and shop currency values. ```json { "currency.presentment": "USD", "currency.shop": "USD", "discounts.presentment": 19.99, "discounts.shop": 19.99, "profit_margin_applied": 0.4, "profit_total.presentment": 19.99, "profit_total.shop": 19.99, "shipping.presentment": 19.99, "shipping.shop": 19.99, "subtotal.presentment": 19.99, "subtotal.shop": 19.99, "tax.presentment": 19.99, "tax.shop": 19.99, "total.presentment": 19.99, "total.shop": 19.99, "total_items.presentment": 19.99, "total_items.shop": 19.99 } ``` -------------------------------- ### discount_codes object JSON example Source: https://help.littledata.io/event-editor/glossary Example JSON object for a discount code applied to an order. Contains amount (number/float), code (string), and type (string, e.g., 'shopify'). ```json { "amount": 19.99, "code": "SUMMER10", "type": "shopify" } ``` -------------------------------- ### shipping_lines object JSON example Source: https://help.littledata.io/event-editor/glossary Example JSON object for a shipping line item on an order. Contains code, price (number/float), and title fields. ```json { "code": "SUMMER10", "price": 19.99, "title": "Blue T-shirt" } ``` -------------------------------- ### client_id object JSON example Source: https://help.littledata.io/event-editor/glossary Example JSON object containing client identifiers from analytics destinations such as GA4, Meta, Google Ads, Klaviyo, and others. All attributes are optional strings. ```json { "attentive.attentive_id": "5821934567", "facebook.fbc": "fb.1.1554763741205.AbCdEfGhIjKlMnOp", "facebook.fbp": "fb.1.1554763741205.234567890", "google_ads.gbraid": "0AAAAA...", "google_ads.gclid": "Cj0KCQjw...", "google_ads.wbraid": "0AAAAB...", "google_analytics4.client_id": "GA1.2.123456789.1234567890", "google_analytics4.session_count": "3", "google_analytics4.session_id": "1234567890", "klaviyo.exchange_id": "5821934567", "microsoft.msclkid": "abcdef1234567890abcdef1234567890", "pinterest.epik": "dj0yJnU9...", "segment.anonymous_id": "5821934567", "tiktok.ttclid": "E.C.P.AbCdEfGhIj", "tiktok.ttp": "01HXXXX" } ``` -------------------------------- ### Customer object JSON example Source: https://help.littledata.io/event-editor/glossary Complete JSON representation of the customer object with all documented attributes, including nested address, email_marketing_consent, and sms_marketing_consent objects. ```json { "address.address1": "123 Main St", "address.address2": "Apt 4", "address.city": "New York", "address.country": "US", "address.country_code": "US", "address.province": "NY", "address.province_code": "NY", "address.zip": "10001", "created_at": "2025-04-15T10:30:00Z", "email": "alice@example.com", "email_marketing_consent.consent_updated_at": "2025-04-15T10:30:00Z", "email_marketing_consent.opt_in_level": "single_opt_in", "email_marketing_consent.state": "subscribed", "first_name": "Alice", "id": "5821934567", "last_name": "Smith", "note": "Leave at front door", "orders_count": 1, "phone": "+1-555-0123", "sms_marketing_consent.consent_updated_at": "2025-04-15T10:30:00Z", "sms_marketing_consent.opt_in_level": "single_opt_in", "sms_marketing_consent.state": "subscribed", "tags": [ "new", "summer" ], "total_spent": 19.99, "updated_at": "2025-04-15T10:30:00Z", "verified_email": true } ``` -------------------------------- ### note_attributes object JSON example Source: https://help.littledata.io/event-editor/glossary Example JSON object for a custom note attribute (key/value pair) attached to an order. Includes internal __ld_attr, name, and value fields. ```json { "__ld_attr": "{\"ga_session_id\":\"1234567890\"}", "name": "Blue T-shirt / Medium", "value": 19.99 } ``` -------------------------------- ### Properties object JSON example Source: https://help.littledata.io/event-editor/glossary Example JSON payload for the properties object, containing order, checkout, customer, and subscription fields. Used as the main data payload for Shopify webhook events. ```json { "create_checkout_url": "https://example.com", "id": "5821934567", "note": "Leave at front door", "abandoned_checkout_url": "https://example.com", "cart_id": "5821934567", "email": "alice@example.com", "landing_site": "https://example.com/products/blue-tshirt", "payment_gateway": "shopify_payments", "phone": "+1-555-0123", "token": "5821934567", "first_name": "Alice", "last_name": "Smith", "presentment_currency": "EUR", "state": "subscribed", "tax_exempt": 19.99, "tax_exemptions": 19.99, "verified_email": true, "location_id": "5821934567", "name": "Blue T-shirt / Medium", "order_id": "5821934567", "order_name": "#1001", "order_number": "1001", "order_type": "REGULAR", "service": "manual", "shipment_status": "in_transit", "status": "active", "tracking_company": "UPS", "tracking_numbers": "1Z999AA10123456784", "tracking_urls": "https://example.com", "checkout_id": "5821934567", "checkout_token": "abc123def456", "fulfillment_status": "fulfilled", "import": true, "order_status_url": "https://example.com", "payment_gateways": "shopify_payments", "tags": [ "new", "summer" ], "cancel_reason": "customer", "cancelled_at": "2025-04-15T10:30:00Z", "return_id": "5821934567", "user_id": "5821934567", "order_interval_frequency": "30", "order_interval_unit": "day", "subscription_id": "5821934567", "cancel_reason_comments": "Customer requested cancellation", "error_type": "card_declined" } ``` -------------------------------- ### Event object JSON example Source: https://help.littledata.io/event-editor/glossary Example JSON payload for the event object, containing event-level metadata such as app ID, subscription app flag, app name, source name, creation timestamp, event ID, and received timestamp. ```json { "app_id": "5821934567", "is_subscription_app": true, "app_name": "Recharge", "source_name": "web", "created_at": "2025-04-15T10:30:00Z", "id": "5821934567", "timestamp": "2025-04-15T10:30:00Z" } ``` -------------------------------- ### Example of hashed first-party data sent to Google Analytics Source: https://help.littledata.io/integrations/shopify-to-google-analytics/tracking-first-party-data-ga4 Shows the JSON payload Littledata sends to GA4 when user-provided data collection is enabled. The data includes hashed email, phone, and address fields using SHA-256. This example is for illustration; actual data will vary. ```json { "user_id":"7158222333381", "user_data":{ "sha256_email_address":"53b61bf697983d0f07a1e4d6962d81a1b86ccf594d32e9bdfb6ad5e110d48b1c", "sha256_phone_number":"f029f7d3dd85b2b7e9b657792d168ab92c48c4363634c59187d5a2dd3279188f", "address":{ "sha256_first_name":"1b99f3740501eaef26b5a0a3958b8fe9e81b822981a414d510b1e5b139348cdf", "sha256_last_name":"e75be31f77b4aae647f4e0b4233bb5cf3b67384434b76ed36f6ff723f79ef1ce", "sha256_street":"4249a5b864b0f3382e9d29c6fd98065fdea6a0ec263fa691842e7e52787aa3e6", "city":"3eef36f440a655f87ec46c3e7e4a61427d3c3549b53c33e34f65fa78ad9ee31d", "region":"124e0b7201b0388d7c07f43194b9645d162b77005b66fef7283c689a69ff7c56", "postal_code":"92c7d71b95dc6540fc58e891dbe649fe72ae5e93b5f42fd7fbdeefe6cef3e51d", "country":"884129b7691d98f541650f9974a034323677ebe4e1c3bd71ebf5d43cdf118acc" } } } ``` -------------------------------- ### Address object JSON example Source: https://help.littledata.io/event-editor/glossary Complete JSON representation of the address object with all documented attributes, including address lines, city, company, country, name fields, phone, postal code, and province. ```json { "address1": "123 Main St", "address2": "Apt 4", "city": "New York", "company": "Acme Inc", "country": "US", "first_name": "Alice", "full_name": "Alice Smith", "last_name": "Smith", "phone": "+1-555-0123", "postal_code": "10001", "province": "NY", "province_code": "NY" } ``` -------------------------------- ### Track extra event with Segment analytics command Source: https://help.littledata.io/advanced/developer/gtm-and-google-analytics-data-layer-for-shopify Use the analytics.track command to send custom events to Segment. This example tracks a 'nav_button_click' event. ```javascript analytics.track('nav_button_click') ``` -------------------------------- ### Sample Segment track event payload for Order Completed Source: https://help.littledata.io/integrations/shopify-to-segment/send-data-from-segment-to-google-analytics Example JSON payload of a Segment track event named 'Order Completed' sent from Shopify via Littledata. It includes context, properties, and integrations data used for mapping to GA4. The integrations.Google Analytics object contains clientId and sessionId values that are referenced in the mapping steps. ```json { "anonymousId": "7d2f31cf-12cd-4fe7-8b61-796b082f792d", "context": { "externalIds": [ { "collection": "users", "encoding": "none", "id": "5451621433524", "type": "shopify_customer_id" } ], "integration": { "name": "shopify_littledata", "version": "9.1" }, "ip": "109.166.139.0", "library": { "name": "analytics-node", "version": "6.2.0" }, "page": { "url": "https://george-littledata.myshopify.com/57897812148/orders/b07de23de195ff866426b18bd8e6a95c/authenticate?key=edebaf51b8746e8b44714c6c9649209e" }, "traits": { "address": { "city": "Bucharest", "country": "Romania", "postalCode": "030333", "state": "București" }, "email": "mockEmail@littledata.io", "firstName": "John", "lastName": "Doe" }, "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36", "userConsent": { "analytics": "no", "marketing": "no", "preferences": "no", "sale_of_data": "" } }, "event": "Order Completed", "id": 5190210224308, "integrations": { "Google Analytics": { "clientId": "635000679.1691589098", "sessionId": "1691589165" } }, "messageId": "node-e9241c5a0bfe61b173cae1fa1f13e1ff-b97ef265-0df8-42f3-9825-79ca1420b6b1", "originalTimestamp": "2023-08-09T13:55:11.696Z", "properties": { "action_source": "system_generated", "affiliation": "Shopify", "app_id": 580111, "cart_id": "ed496915e493c6f840aa326d3ebc546d", "category": "Shopify (Littledata)", "checkout_id": 30049366999220, "currency": "GBP", "email": "johndoe@littledata.io", "fbp": "fb.1.1691589233972.1542748812", "lifetime_revenue_littledata": "0.00", "order_id": "#1332", "presentment_amount": "1248.99", "presentment_currency": "GBP", "products": [ { "brand": "george-littledata", "category": "Metallica", "compare_at_price": "1346.00", "image_url": "https://cdn.shopify.com/s/files/1/0578/9781/2148/products/NewFourHorsementTshirt.jpg?v=1667494039", "name": "Tricou cu Metallica", "presentment_amount": "1234.00", "presentment_currency": "GBP", "price": 1234, "product_id": "7306213753012", "quantity": 1, "shopify_product_id": "7306213753012", "shopify_variant_id": "42003742982324", "sku": "", "url": "https://george-littledata.myshopify.com/products/tricou-cu-metallica", "variant": "Default Title" } ], "purchase_count_littledata": 0, "sent_from": "Littledata app", "shipping": 14.99, "shopify_customer_id_littledata": 5451621433524, "source_name": "web", "subtotal": 1234, "tax": 0, "total": 1248.99 }, "receivedAt": "2023-08-09T13:55:11.967Z", "receivedDate": "2023-08-09T13:55:11.144Z", "sentAt": "2023-08-09T13:55:11.698Z", "shopID": "qZMKeB4Y6HRRgKkxs", "timestamp": "2023-08-09T13:55:11.965Z", "transaction": true, "type": "track", "userId": "5451621433524", "writeKey": "SbjsudVDtq96preF33MZ6UzxSttXrtRZ" } ``` -------------------------------- ### Minified script for Shopify theme.liquid to track Gorgias events Source: https://help.littledata.io/partner-recipes/gorgias/tracking-gorgias-google-analytics Paste this script into the Shopify theme.liquid file. It waits for the Gorgias widget to load, then listens to chat events and sends them to Google Analytics via gtag. If gtag has not loaded yet, events are queued until Google Analytics is ready. ```html ``` -------------------------------- ### Raw script for adapting Gorgias event tracking Source: https://help.littledata.io/partner-recipes/gorgias/tracking-gorgias-google-analytics Full script without HTML wrapper, provided for adaptation to track different events or send to different data destinations. It maps Gorgias events to Google Analytics event names and uses gtag to send them. ```javascript var eventsToTrack = [ { gorgias: "message:sent", ga: "gorgias_message_sent", }, { gorgias: "message:received", ga: "gorgias_message_received", }, { gorgias: "widget:opened", ga: "gorgias_widget_opened", }, { gorgias: "widget:closed", ga: "gorgias_widget_closed", }, ]; var initGorgiasChatPromise = window.GorgiasChat ? window.GorgiasChat.init() : new Promise(function (resolve) { window.addEventListener("gorgias-widget-loaded", function () { resolve(); }); }); initGorgiasChatPromise.then(function () { eventsToTrack.forEach(function (event) { GorgiasChat.on(event.gorgias, function (data) { gtag && gtag("event", event.ga); }); }); }); ``` -------------------------------- ### Rebuy Smart Cart tracking script for Google Analytics Source: https://help.littledata.io/partner-recipes/rebuy/tracking-rebuy-smartcart Paste this script into the Shopify theme.liquid file or assets loaded from the theme. It listens for Rebuy Smart Cart events and sends them to Google Analytics via the gtag library. If gtag is not yet loaded, events are queued until GA is ready. ```html ``` -------------------------------- ### Littledata script snippet for theme.gem-layout-none.liquid Source: https://help.littledata.io/partner-recipes/landing-page-apps/gempages Paste this code before the closing tag in theme.gem-layout-none.liquid when the Gem Pages 'Header & footer' setting is OFF. It includes the LittledataLayer snippet to fix Google Analytics. ```liquid {% include 'LittledataLayer' %} ``` -------------------------------- ### Customer data layer variable when logged in Source: https://help.littledata.io/advanced/developer/gtm-and-google-analytics-data-layer-for-shopify The LittledataLayer includes a customer object when a customer is logged in, containing Shopify customer ID, name, email, and phone. ```json { ... customer: { id: '1234', // same as Shopify customer ID name: 'John Smith', email: 'john@smith.com', phone: '+442083508061' } } ``` -------------------------------- ### Block client-side events based on consent with AnalyticsJS middleware Source: https://help.littledata.io/integrations/shopify-to-segment/segment-consent-management Use this middleware script to drop events from being triggered if `context.consent.categoryPreferences.Advertising` is not `true`. It temporarily implements `addSourceMiddleware` before the real script loads. ```javascript window.analytics = window.analytics || []; // Temporary implementation before the real script loads if (!window.analytics.addSourceMiddleware) { window.analytics.addSourceMiddleware = function () { const e = Array.prototype.slice.call(arguments); e.unshift('addSourceMiddleware'); window.analytics.push(e); return window.analytics; }; } window.analytics.addSourceMiddleware(({ payload, next }) => { if(payload?.obj?.context?.consent?.categoryPreferences?.Advertising) { next(payload); } }); ``` -------------------------------- ### Track a custom event with parameters using gtag Source: https://help.littledata.io/advanced/developer/gtm-and-google-analytics-data-layer-for-shopify Use this snippet to track a custom event with additional parameters, such as promo details, in Google Analytics. The parameters are passed as an object to gtag. ```javascript gtag('track', 'promo_click', { 'promo_name': 'BIG BANNER', 'promo_location': 'HOMEPAGE' }) ``` -------------------------------- ### Check cart attributes for client ID in browser console Source: https://help.littledata.io/advanced/troubleshooting/troubleshooting-marketing-attribution-for-shopify Use this snippet in the browser console to request the current Shopify cart and verify that the `attributes` field contains `google-clientID` or `segment-clientID`. If the attribute is missing, it logs 'Client ID attribute missing'. ```javascript 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(); ``` -------------------------------- ### Track a custom event with gtag Source: https://help.littledata.io/advanced/developer/gtm-and-google-analytics-data-layer-for-shopify Use this snippet to track a custom event, such as a navigation button click, in Google Analytics. Littledata's app embed loads gtag.js on all pages, and the event queue handles calls before the library loads. ```javascript gtag('track', 'nav_button_click') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.