Server-Side Tracking for Cratejoy
Stop losing conversions to iOS ITP, short-lived cookies, and ad-blockers. TrakSolv hosts a first-party server-side GTM container for your Cratejoy store and forwards clean, deduplicated conversions to GA4, Meta CAPI, Google Ads and more. Live in minutes, flat monthly pricing.
The pixel alone is leaking your data.
Browser-side tracking on Cratejoy loses a growing share of conversions. Here's what moving to a server-side setup fixes.
Recover conversions lost to ITP & ad-blockers
On Cratejoy, browser-side pixels are throttled by Safari/Firefox ITP, capped 7-day cookies, and blocked outright by ad-blockers and consent walls. Server-side tracking moves the measurement off the browser, so purchases and add-to-carts that the pixel silently drops are recovered and reported.
First-party data, served from your own domain
TrakSolv hosts your Google Tag Manager server container on a subdomain of your Cratejoy site. Requests come from a first-party context — they survive 3rd-party cookie deprecation, last far longer than client-side cookies, and look like your own traffic, not a tracker.
Clean, deduplicated conversions to every ad platform
The Cratejoy dataLayer fires every GA4 enhanced-ecommerce event with a stable event_id, so your server-side container can forward purchases and add-to-carts to GA4, Meta CAPI, Google Ads Enhanced Conversions, TikTok and more — deduplicated against the browser pixel, with higher match quality.
How to set up server-side tracking on Cratejoy
Paste the TrakSolv loader and the Cratejoy dataLayer snippet into your store's custom-code area, save, and you're done. Every step below has the exact snippet with a copy button.
Install guide
How to install on Cratejoy
This is your install. Every step below has its exact snippet with a Copy button — go step by step. The Loader card above and DataLayer card below are reference copies of the same snippets.
- 1
Open Cratejoy theme code editor
NavigateCratejoy Admin → Design → Code
Cratejoy uses Liquid-style templates split between base.html (site-wide) and per-component HTML files. We need to paste in TWO different files — base.html for site-wide tracking, thank_you/component.html for the purchase event.
- 2
Loader — head half
Loader • HeadDesign → Code → HTML → base.html → paste the Loader Head snippet inside <head>
- 3
Loader — body half + Setup DataLayer (base.html)
Loader • BodySame base.html, near the bottom before </body> → paste the Loader Body snippet FIRST
- 4
Setup DataLayer (Snippet 1 of 2)
DataLayerSame base.html, after the Loader Body → paste 'Snippet 1 of 2 — Setup' from the DataLayer card
Covers view_item / view_item_list / view_cart / begin_checkout on every Cratejoy page.
HTML/* === Snippet 1 of 2 — Setup (base.html) === */ <!-- Traksolv · Cratejoy Setup — Design → Code → base.html → paste in <head> --> <script> (function (w, d) { w.dataLayer = w.dataLayer || []; var DEBUG = false; try { var q = new URLSearchParams(location.search); if (q.get('tcDebug') === '1') { DEBUG = true; try { localStorage.setItem('tcDebug', '1'); } catch (e) {} } else if (q.get('tcDebug') === '0') { DEBUG = false; try { localStorage.removeItem('tcDebug'); } catch (e) {} } else { try { if (localStorage.getItem('tcDebug') === '1') DEBUG = true; } catch (e) {} } } catch (e) {} w.tcDebug = DEBUG; if (DEBUG && w.console && w.console.log) { try { w.console.log('%c[Traksolv]%c dataLayer debug ON — every push will log here. Disable with ?tcDebug=0', 'color:#22c55e;font-weight:600;background:#0a1f0c;padding:2px 6px;border-radius:3px', ''); } catch (e) {} } function log() { if (!DEBUG || !w.console || !w.console.log) return; try { w.console.log.apply(w.console, ['[Traksolv]'].concat([].slice.call(arguments))); } catch (e) {} } function push(eventName, eventId, params) { try { if (params && params.ecommerce !== undefined) w.dataLayer.push({ ecommerce: null }); var ev = { event: eventName, event_id: eventName + '.' + eventId }; if (params) for (var k in params) if (Object.prototype.hasOwnProperty.call(params, k)) ev[k] = params[k]; w.dataLayer.push(ev); log('push ' + eventName, ev); } catch (e) {} } function once(key) { try { if (sessionStorage.getItem(key)) return false; sessionStorage.setItem(key, '1'); return true; } catch (e) { return true; } } function money(v) { return parseFloat(String(v == null ? '' : v).replace(/[^\d.\-]/g, '')) || 0; } function textOf(sel, root) { var el = (root || d).querySelector(sel); return el ? (el.textContent || '').trim() : ''; } function attrOf(sel, a) { var el = d.querySelector(sel); return el ? (el.getAttribute(a) || '') : ''; } w.tcFirePurchase = function (o) { try { if (!o || !o.orderId) return; if (!once('tc_purchase_' + o.orderId)) return; push('purchase', String(o.orderId), { ecommerce: { transaction_id: String(o.orderId), value: Number(o.value) || 0, currency: o.currency || 'USD', items: Array.isArray(o.items) ? o.items : [] } }); } catch (e) {} }; function pageType() { var path = (location.pathname || '').toLowerCase(); if (/\/thank_you/.test(path)) return 'thank-you'; if (/\/checkout/.test(path)) return 'checkout'; if (/^\/cart/.test(path)) return 'cart'; if (/\/listing\/[^\/]+/.test(path)) return 'product'; if (/\/listings\b|\/marketplace/.test(path)) return 'category'; return 'other'; } w.tcPageType = pageType; function fireViewItem() { try { var slug = (location.pathname.match(/\/listing\/([^\/?]+)/) || [])[1]; if (!slug) return; if (!once('tc_view_item_' + slug)) return; var name = textOf('h1, h1.product-title, h1.listing-title') || slug; var price = money(textOf('.price, .listing-price, [itemprop="price"]') || attrOf('meta[itemprop="price"]', 'content')); push('view_item', String(slug), { ecommerce: { currency: 'USD', value: price, items: [{ item_id: String(slug), item_name: name, item_category: 'subscription', price: price, quantity: 1 }] } }); } catch (e) {} } function fireViewItemList() { try { var cards = d.querySelectorAll('.listing-card, .product-card, .listing, a[href*="/listing/"]'); if (!cards.length) return; if (!once('tc_view_item_list_' + location.pathname)) return; var items = []; var seen = {}; for (var i = 0; i < Math.min(cards.length, 25); i++) { var c = cards[i]; var link = c.tagName === 'A' ? c : c.querySelector('a[href*="/listing/"]'); var slug = link ? (link.href.match(/\/listing\/([^\/?]+)/) || [])[1] : ''; if (!slug || seen[slug]) continue; seen[slug] = true; items.push({ item_id: String(slug), item_name: textOf('h2, h3, .listing-title, .title', c) || slug, price: money(textOf('.price', c)), index: items.length }); } if (!items.length) return; push('view_item_list', location.pathname, { ecommerce: { item_list_id: location.pathname, item_list_name: textOf('h1') || location.pathname, items: items } }); } catch (e) {} } function readCartRows() { var rows = d.querySelectorAll('.cart-item, .cart__item, .order-item'); var items = []; var total = 0; for (var i = 0; i < rows.length; i++) { var r = rows[i]; var name = textOf('.cart-item-name, .product-name, a', r); var price = money(textOf('.cart-item-price, .price', r)); var qty = parseInt((textOf('.cart-item-quantity, input[name*="quantity"]', r) || '1').replace(/\D/g, '') || '1', 10) || 1; items.push({ item_id: name || ('item.' + i), item_name: name, price: price, quantity: qty }); total += price * qty; } return { items: items, total: total }; } function fireCart(eventName) { try { var c = readCartRows(); if (!c.items.length) return; var key = location.pathname + '.' + c.items.length; if (!once('tc_' + eventName + '_' + key)) return; push(eventName, key.slice(0, 64), { ecommerce: { currency: 'USD', value: c.total, items: c.items } }); } catch (e) {} } function boot() { var t = pageType(); if (t === 'product') fireViewItem(); if (t === 'category') fireViewItemList(); if (t === 'cart') fireCart('view_cart'); if (t === 'checkout') fireCart('begin_checkout'); // 'thank-you' is handled by the separate Purchase snippet — Liquid // {{ order.* }} markup only renders inside the thank_you template. } if (d.readyState === 'loading') d.addEventListener('DOMContentLoaded', boot); else boot(); })(window, document); </script> <!-- End Traksolv Cratejoy Setup --> <!-- Traksolv · DataLayer enrichment — customer lifecycle + remarketing + attribution --> <script> (function (w, d) { function readLT() { try { var raw = localStorage.getItem('tc_lifetime'); var p = raw ? JSON.parse(raw) : null; return { orderCount: (p && p.orderCount) || 0, lifetimeValue: (p && p.lifetimeValue) || 0, firstOrderTs: (p && p.firstOrderTs) || null, lastOrderTs: (p && p.lastOrderTs) || null, lastOrderId: (p && p.lastOrderId) || null }; } catch (e) { return { orderCount: 0, lifetimeValue: 0, firstOrderTs: null, lastOrderTs: null, lastOrderId: null }; } } function writeLT(lt) { try { localStorage.setItem('tc_lifetime', JSON.stringify(lt)); } catch (e) {} } function tier(v) { if (v >= 1000) return 'vip'; if (v >= 250) return 'mid'; if (v > 0) return 'low'; return 'guest'; } function readCookie(n) { try { var m = d.cookie.match(new RegExp('(^|; )' + n + '=([^;]+)')); return m ? decodeURIComponent(m[2]) : null; } catch (e) { return null; } } function readAttr() { try { var r = readCookie('_tc_attr'); return r ? JSON.parse(r) : null; } catch (e) { return null; } } w.tcReadLifetime = readLT; w.tcCustomerTier = function (v) { return tier(v != null ? v : readLT().lifetimeValue); }; w.tcReadAttribution = readAttr; // ── Wrap tcFirePurchase to add customer-lifecycle + attribution ── // before the underlying snippet pushes the purchase event. Idempotent // per orderId, so customer refreshing the thank-you page doesn't // inflate their lifetime counters. var orig = w.tcFirePurchase; if (typeof orig === 'function') { w.tcFirePurchase = function (o) { try { if (!o || !o.orderId) return orig.apply(this, arguments); var lt = readLT(); var firstFire = lt.lastOrderId !== String(o.orderId); var orderCount = firstFire ? lt.orderCount + 1 : lt.orderCount; var lifetimeValue = firstFire ? lt.lifetimeValue + (o.value || 0) : lt.lifetimeValue; var firstOrderTs = lt.firstOrderTs || Date.now(); var newCustomer = orderCount === 1; var daysSinceFirst = Math.floor((Date.now() - firstOrderTs) / 86400000); if (firstFire) { writeLT({ orderCount: orderCount, lifetimeValue: lifetimeValue, firstOrderTs: firstOrderTs, lastOrderTs: Date.now(), lastOrderId: String(o.orderId) }); } var attr = readAttr(); // Build the enriched order. Preserve every original field; add // customer + attribution on top. var enriched = {}; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) enriched[k] = o[k]; enriched.new_customer = newCustomer; enriched.customer_type = newCustomer ? 'new' : 'returning'; enriched.customer_status = 'customer'; enriched.customer_lifetime_value = Math.round(lifetimeValue * 100) / 100; enriched.customer_order_count = orderCount; enriched.customer_aov = orderCount > 0 ? Math.round((lifetimeValue / orderCount) * 100) / 100 : 0; enriched.purchase_number = orderCount; enriched.days_since_first_order = daysSinceFirst; enriched.value_tier = tier(lifetimeValue); if (attr) enriched.attribution = { landing: attr.u || null, referrer: attr.r || null, utm: attr.utm || null, click_ids: attr.cid || null }; return orig.call(this, enriched); } catch (e) { try { return orig.apply(this, arguments); } catch (e2) {} } }; } // ── tc_visitor_context — emits visitor lifecycle + remarketing on // every page-view. GTM / GA4 audience triggers + Google Ads // dynamic remarketing tag read these. function visitorContext() { try { var lt = readLT(); var attr = readAttr(); var pageType = (typeof w.tcPageType === 'function') ? (w.tcPageType() || 'other') : 'other'; w.dataLayer = w.dataLayer || []; w.dataLayer.push({ event: 'tc_visitor_context', event_id: 'tc_visitor_context.' + Date.now() + '.' + Math.random().toString(36).slice(2, 6), customer_status: lt.orderCount > 0 ? 'returning_customer' : 'guest', customer_type: lt.orderCount > 0 ? 'returning' : 'guest', value_tier: tier(lt.lifetimeValue), customer_lifetime_value: Math.round(lt.lifetimeValue * 100) / 100, customer_order_count: lt.orderCount, days_since_first_order: lt.firstOrderTs ? Math.floor((Date.now() - lt.firstOrderTs) / 86400000) : null, ecomm_pagetype: pageType, attribution: attr ? { landing: attr.u || null, referrer: attr.r || null, utm: attr.utm || null, click_ids: attr.cid || null } : null }); } catch (e) {} } if (d.readyState === 'loading') d.addEventListener('DOMContentLoaded', visitorContext); else visitorContext(); })(window, document); </script> <!-- End Traksolv enrichment --> /* === Snippet 2 of 2 — Purchase (thank_you component) === */ <!-- Traksolv · Cratejoy Purchase — Design → thank_you → component.html --> <script> (function (w) { w.dataLayer = w.dataLayer || []; function push(eventName, eventId, params) { try { if (params && params.ecommerce !== undefined) w.dataLayer.push({ ecommerce: null }); var ev = { event: eventName, event_id: eventName + '.' + eventId }; if (params) for (var k in params) if (Object.prototype.hasOwnProperty.call(params, k)) ev[k] = params[k]; w.dataLayer.push(ev); } catch (e) {} } // Cratejoy Liquid variables — substituted at render time. var orderId = "{{ order.id }}"; var total = parseFloat("{{ order.total }}") || 0; var subtotal= parseFloat("{{ order.subtotal }}") || 0; var tax = parseFloat("{{ order.tax }}") || undefined; var shipping= parseFloat("{{ order.shipping }}") || undefined; var email = "{{ order.email }}"; try { if (sessionStorage.getItem('tc_purchase_' + orderId)) return; sessionStorage.setItem('tc_purchase_' + orderId, '1'); } catch (e) {} push('purchase', String(orderId), { ecommerce: { transaction_id: String(orderId), affiliation: 'Cratejoy', value: total, subtotal: subtotal || undefined, tax: tax, shipping: shipping, currency: 'USD', items: [{ item_id: 'cratejoy-order-' + orderId, item_name: 'Cratejoy subscription order', item_category: 'subscription', price: total, quantity: 1 }] }, user_email: email || undefined }); })(window); </script> <!-- End Traksolv Cratejoy Purchase --> - 5
Purchase DataLayer (Snippet 2 of 2)
DataLayerDesign → Code → Components → customer → thank_you → Customer Thank You Content → component.html → paste 'Snippet 2 of 2 — Purchase'
Uses Cratejoy's {{ order.id }} / {{ order.total }} / {{ order.email }} Liquid variables — substituted at render time so real values land in the dataLayer.
HTML/* === Snippet 1 of 2 — Setup (base.html) === */ <!-- Traksolv · Cratejoy Setup — Design → Code → base.html → paste in <head> --> <script> (function (w, d) { w.dataLayer = w.dataLayer || []; var DEBUG = false; try { var q = new URLSearchParams(location.search); if (q.get('tcDebug') === '1') { DEBUG = true; try { localStorage.setItem('tcDebug', '1'); } catch (e) {} } else if (q.get('tcDebug') === '0') { DEBUG = false; try { localStorage.removeItem('tcDebug'); } catch (e) {} } else { try { if (localStorage.getItem('tcDebug') === '1') DEBUG = true; } catch (e) {} } } catch (e) {} w.tcDebug = DEBUG; if (DEBUG && w.console && w.console.log) { try { w.console.log('%c[Traksolv]%c dataLayer debug ON — every push will log here. Disable with ?tcDebug=0', 'color:#22c55e;font-weight:600;background:#0a1f0c;padding:2px 6px;border-radius:3px', ''); } catch (e) {} } function log() { if (!DEBUG || !w.console || !w.console.log) return; try { w.console.log.apply(w.console, ['[Traksolv]'].concat([].slice.call(arguments))); } catch (e) {} } function push(eventName, eventId, params) { try { if (params && params.ecommerce !== undefined) w.dataLayer.push({ ecommerce: null }); var ev = { event: eventName, event_id: eventName + '.' + eventId }; if (params) for (var k in params) if (Object.prototype.hasOwnProperty.call(params, k)) ev[k] = params[k]; w.dataLayer.push(ev); log('push ' + eventName, ev); } catch (e) {} } function once(key) { try { if (sessionStorage.getItem(key)) return false; sessionStorage.setItem(key, '1'); return true; } catch (e) { return true; } } function money(v) { return parseFloat(String(v == null ? '' : v).replace(/[^\d.\-]/g, '')) || 0; } function textOf(sel, root) { var el = (root || d).querySelector(sel); return el ? (el.textContent || '').trim() : ''; } function attrOf(sel, a) { var el = d.querySelector(sel); return el ? (el.getAttribute(a) || '') : ''; } w.tcFirePurchase = function (o) { try { if (!o || !o.orderId) return; if (!once('tc_purchase_' + o.orderId)) return; push('purchase', String(o.orderId), { ecommerce: { transaction_id: String(o.orderId), value: Number(o.value) || 0, currency: o.currency || 'USD', items: Array.isArray(o.items) ? o.items : [] } }); } catch (e) {} }; function pageType() { var path = (location.pathname || '').toLowerCase(); if (/\/thank_you/.test(path)) return 'thank-you'; if (/\/checkout/.test(path)) return 'checkout'; if (/^\/cart/.test(path)) return 'cart'; if (/\/listing\/[^\/]+/.test(path)) return 'product'; if (/\/listings\b|\/marketplace/.test(path)) return 'category'; return 'other'; } w.tcPageType = pageType; function fireViewItem() { try { var slug = (location.pathname.match(/\/listing\/([^\/?]+)/) || [])[1]; if (!slug) return; if (!once('tc_view_item_' + slug)) return; var name = textOf('h1, h1.product-title, h1.listing-title') || slug; var price = money(textOf('.price, .listing-price, [itemprop="price"]') || attrOf('meta[itemprop="price"]', 'content')); push('view_item', String(slug), { ecommerce: { currency: 'USD', value: price, items: [{ item_id: String(slug), item_name: name, item_category: 'subscription', price: price, quantity: 1 }] } }); } catch (e) {} } function fireViewItemList() { try { var cards = d.querySelectorAll('.listing-card, .product-card, .listing, a[href*="/listing/"]'); if (!cards.length) return; if (!once('tc_view_item_list_' + location.pathname)) return; var items = []; var seen = {}; for (var i = 0; i < Math.min(cards.length, 25); i++) { var c = cards[i]; var link = c.tagName === 'A' ? c : c.querySelector('a[href*="/listing/"]'); var slug = link ? (link.href.match(/\/listing\/([^\/?]+)/) || [])[1] : ''; if (!slug || seen[slug]) continue; seen[slug] = true; items.push({ item_id: String(slug), item_name: textOf('h2, h3, .listing-title, .title', c) || slug, price: money(textOf('.price', c)), index: items.length }); } if (!items.length) return; push('view_item_list', location.pathname, { ecommerce: { item_list_id: location.pathname, item_list_name: textOf('h1') || location.pathname, items: items } }); } catch (e) {} } function readCartRows() { var rows = d.querySelectorAll('.cart-item, .cart__item, .order-item'); var items = []; var total = 0; for (var i = 0; i < rows.length; i++) { var r = rows[i]; var name = textOf('.cart-item-name, .product-name, a', r); var price = money(textOf('.cart-item-price, .price', r)); var qty = parseInt((textOf('.cart-item-quantity, input[name*="quantity"]', r) || '1').replace(/\D/g, '') || '1', 10) || 1; items.push({ item_id: name || ('item.' + i), item_name: name, price: price, quantity: qty }); total += price * qty; } return { items: items, total: total }; } function fireCart(eventName) { try { var c = readCartRows(); if (!c.items.length) return; var key = location.pathname + '.' + c.items.length; if (!once('tc_' + eventName + '_' + key)) return; push(eventName, key.slice(0, 64), { ecommerce: { currency: 'USD', value: c.total, items: c.items } }); } catch (e) {} } function boot() { var t = pageType(); if (t === 'product') fireViewItem(); if (t === 'category') fireViewItemList(); if (t === 'cart') fireCart('view_cart'); if (t === 'checkout') fireCart('begin_checkout'); // 'thank-you' is handled by the separate Purchase snippet — Liquid // {{ order.* }} markup only renders inside the thank_you template. } if (d.readyState === 'loading') d.addEventListener('DOMContentLoaded', boot); else boot(); })(window, document); </script> <!-- End Traksolv Cratejoy Setup --> <!-- Traksolv · DataLayer enrichment — customer lifecycle + remarketing + attribution --> <script> (function (w, d) { function readLT() { try { var raw = localStorage.getItem('tc_lifetime'); var p = raw ? JSON.parse(raw) : null; return { orderCount: (p && p.orderCount) || 0, lifetimeValue: (p && p.lifetimeValue) || 0, firstOrderTs: (p && p.firstOrderTs) || null, lastOrderTs: (p && p.lastOrderTs) || null, lastOrderId: (p && p.lastOrderId) || null }; } catch (e) { return { orderCount: 0, lifetimeValue: 0, firstOrderTs: null, lastOrderTs: null, lastOrderId: null }; } } function writeLT(lt) { try { localStorage.setItem('tc_lifetime', JSON.stringify(lt)); } catch (e) {} } function tier(v) { if (v >= 1000) return 'vip'; if (v >= 250) return 'mid'; if (v > 0) return 'low'; return 'guest'; } function readCookie(n) { try { var m = d.cookie.match(new RegExp('(^|; )' + n + '=([^;]+)')); return m ? decodeURIComponent(m[2]) : null; } catch (e) { return null; } } function readAttr() { try { var r = readCookie('_tc_attr'); return r ? JSON.parse(r) : null; } catch (e) { return null; } } w.tcReadLifetime = readLT; w.tcCustomerTier = function (v) { return tier(v != null ? v : readLT().lifetimeValue); }; w.tcReadAttribution = readAttr; // ── Wrap tcFirePurchase to add customer-lifecycle + attribution ── // before the underlying snippet pushes the purchase event. Idempotent // per orderId, so customer refreshing the thank-you page doesn't // inflate their lifetime counters. var orig = w.tcFirePurchase; if (typeof orig === 'function') { w.tcFirePurchase = function (o) { try { if (!o || !o.orderId) return orig.apply(this, arguments); var lt = readLT(); var firstFire = lt.lastOrderId !== String(o.orderId); var orderCount = firstFire ? lt.orderCount + 1 : lt.orderCount; var lifetimeValue = firstFire ? lt.lifetimeValue + (o.value || 0) : lt.lifetimeValue; var firstOrderTs = lt.firstOrderTs || Date.now(); var newCustomer = orderCount === 1; var daysSinceFirst = Math.floor((Date.now() - firstOrderTs) / 86400000); if (firstFire) { writeLT({ orderCount: orderCount, lifetimeValue: lifetimeValue, firstOrderTs: firstOrderTs, lastOrderTs: Date.now(), lastOrderId: String(o.orderId) }); } var attr = readAttr(); // Build the enriched order. Preserve every original field; add // customer + attribution on top. var enriched = {}; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) enriched[k] = o[k]; enriched.new_customer = newCustomer; enriched.customer_type = newCustomer ? 'new' : 'returning'; enriched.customer_status = 'customer'; enriched.customer_lifetime_value = Math.round(lifetimeValue * 100) / 100; enriched.customer_order_count = orderCount; enriched.customer_aov = orderCount > 0 ? Math.round((lifetimeValue / orderCount) * 100) / 100 : 0; enriched.purchase_number = orderCount; enriched.days_since_first_order = daysSinceFirst; enriched.value_tier = tier(lifetimeValue); if (attr) enriched.attribution = { landing: attr.u || null, referrer: attr.r || null, utm: attr.utm || null, click_ids: attr.cid || null }; return orig.call(this, enriched); } catch (e) { try { return orig.apply(this, arguments); } catch (e2) {} } }; } // ── tc_visitor_context — emits visitor lifecycle + remarketing on // every page-view. GTM / GA4 audience triggers + Google Ads // dynamic remarketing tag read these. function visitorContext() { try { var lt = readLT(); var attr = readAttr(); var pageType = (typeof w.tcPageType === 'function') ? (w.tcPageType() || 'other') : 'other'; w.dataLayer = w.dataLayer || []; w.dataLayer.push({ event: 'tc_visitor_context', event_id: 'tc_visitor_context.' + Date.now() + '.' + Math.random().toString(36).slice(2, 6), customer_status: lt.orderCount > 0 ? 'returning_customer' : 'guest', customer_type: lt.orderCount > 0 ? 'returning' : 'guest', value_tier: tier(lt.lifetimeValue), customer_lifetime_value: Math.round(lt.lifetimeValue * 100) / 100, customer_order_count: lt.orderCount, days_since_first_order: lt.firstOrderTs ? Math.floor((Date.now() - lt.firstOrderTs) / 86400000) : null, ecomm_pagetype: pageType, attribution: attr ? { landing: attr.u || null, referrer: attr.r || null, utm: attr.utm || null, click_ids: attr.cid || null } : null }); } catch (e) {} } if (d.readyState === 'loading') d.addEventListener('DOMContentLoaded', visitorContext); else visitorContext(); })(window, document); </script> <!-- End Traksolv enrichment --> /* === Snippet 2 of 2 — Purchase (thank_you component) === */ <!-- Traksolv · Cratejoy Purchase — Design → thank_you → component.html --> <script> (function (w) { w.dataLayer = w.dataLayer || []; function push(eventName, eventId, params) { try { if (params && params.ecommerce !== undefined) w.dataLayer.push({ ecommerce: null }); var ev = { event: eventName, event_id: eventName + '.' + eventId }; if (params) for (var k in params) if (Object.prototype.hasOwnProperty.call(params, k)) ev[k] = params[k]; w.dataLayer.push(ev); } catch (e) {} } // Cratejoy Liquid variables — substituted at render time. var orderId = "{{ order.id }}"; var total = parseFloat("{{ order.total }}") || 0; var subtotal= parseFloat("{{ order.subtotal }}") || 0; var tax = parseFloat("{{ order.tax }}") || undefined; var shipping= parseFloat("{{ order.shipping }}") || undefined; var email = "{{ order.email }}"; try { if (sessionStorage.getItem('tc_purchase_' + orderId)) return; sessionStorage.setItem('tc_purchase_' + orderId, '1'); } catch (e) {} push('purchase', String(orderId), { ecommerce: { transaction_id: String(orderId), affiliation: 'Cratejoy', value: total, subtotal: subtotal || undefined, tax: tax, shipping: shipping, currency: 'USD', items: [{ item_id: 'cratejoy-order-' + orderId, item_name: 'Cratejoy subscription order', item_category: 'subscription', price: total, quantity: 1 }] }, user_email: email || undefined }); })(window); </script> <!-- End Traksolv Cratejoy Purchase --> - 6
Save and test with a $0 box
SaveSave both files → checkout a $0 test subscription → verify purchase fires on the thank-you page
?tcDebug=1 in the URL will log dataLayer pushes to console.
The loader Head + Body snippets are generated for your container inside the TrakSolv dashboard. Create a free account to grab them, or see the full how-it-works walkthrough.
Server-side tracking for Cratejoy, answered
Does server-side tracking work with Cratejoy?
Yes. TrakSolv works with Cratejoy via a lightweight loader snippet plus a Cratejoy-specific dataLayer that fires every GA4 enhanced-ecommerce event. You paste it once in Cratejoy's custom-code area and conversions start flowing through your own server-side GTM container.
How do I install TrakSolv on Cratejoy?
Add the TrakSolv loader (head + body) and the Cratejoy dataLayer snippet to your store's custom-code settings, then save. The full step-by-step is on this page. Most Cratejoy merchants are live in a few minutes — no developer required.
What can I track server-side on Cratejoy?
Page views, product views, purchases and add-to-carts, begin-checkout and more — every standard GA4 enhanced-ecommerce event, forwarded server-side to GA4, Meta CAPI, Google Ads and other destinations with deduplication.
How much does server-side tracking for Cratejoy cost?
TrakSolv uses flat monthly pricing — one event sent to many destinations still counts as one event, and paid plans never auto-pause at quota. You can start free and go live in minutes.
Recover your Cratejoy conversions — start free.
Spin up a first-party server-side GTM container for Cratejoy and watch your match quality climb. No credit card, live in minutes.
