Site builder

Server-Side Tracking for Tilda

Stop losing conversions to iOS ITP, short-lived cookies, and ad-blockers. TrakSolv hosts a first-party server-side GTM container for your Tilda store and forwards clean, deduplicated conversions to GA4, Meta CAPI, Google Ads and more. Live in minutes, flat monthly pricing.

No credit card to startFlat monthly pricingNative Tilda dataLayerGA4 · Meta CAPI · Google Ads
Why it matters for Tilda

The pixel alone is leaking your data.

Browser-side tracking on Tilda loses a growing share of conversions. Here's what moving to a server-side setup fixes.

Recover conversions lost to ITP & ad-blockers

On Tilda, 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 leads and purchases 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 Tilda 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 Tilda dataLayer fires every GA4 enhanced-ecommerce event with a stable event_id, so your server-side container can forward leads and purchases to GA4, Meta CAPI, Google Ads Enhanced Conversions, TikTok and more — deduplicated against the browser pixel, with higher match quality.

Step by step

How to set up server-side tracking on Tilda

Paste the TrakSolv loader and the Tilda 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 Tilda

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. 1

    Open Site Settings → More

    Navigate

    Tilda → Site Settings → More → 'HTML code for the head section for all pages'

    Site-wide head injection is the recommended install. For per-page only, use Page Settings → Additional → HTML code instead, OR drop a T123 'Embed HTML code' block on a specific page.

  2. 2

    Loader — head half

    Loader • Head

    HTML code for the head section → paste the Loader Head snippet at the top

  3. 3

    Loader — body half + DataLayer (same head field)

    Loader • Body

    Same head section field → append the Loader Body snippet after the Head

    Tilda only exposes a single HTML-for-head field — the Loader Body goes there too. The Loader supports either position.

  4. 4

    DataLayer snippet

    DataLayer

    Same head section field → append the DataLayer snippet right after the Body

    Subscribes to localStorage 'tcart' for live cart events + reads data-product-* attributes on Tilda Store product cards.

    HTML
    <!-- Traksolv · Tilda DataLayer — Site Settings → More → HTML for head section -->
    <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; }
    
      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|success|order[-_]?(confirm|complete|success)|spasibo)/.test(path) || d.querySelector('#successbox, .t-store-success, .t706__success')) return 'thank-you';
        if (d.querySelector('.t-store__prod-popup, .t-store__prod, .js-product-controls')) return 'product';
        if (d.querySelector('.t-store__card')) return 'category';
        return 'other';
      }
      w.tcPageType = pageType;
    
      function readTcart() {
        try {
          var raw = localStorage.getItem('tcart');
          if (!raw) return null;
          return JSON.parse(raw);
        } catch (e) { return null; }
      }
    
      function tildaItem(p, i) {
        return {
          item_id:       String(p.uid || p.id || p.name || ('item.' + i)),
          item_name:     p.name || '',
          item_category: (p.cat && p.cat[0]) || undefined,
          item_variant:  p.options && p.options.length ? p.options.map(function (o) { return o.option + ':' + o.variant; }).join(' / ') : undefined,
          price:         Number(p.price) || Number(p.amount) || 0,
          quantity:      Number(p.quantity) || 1,
          index:         typeof i === 'number' ? i : undefined
        };
      }
    
      // ── PDP — read product card / popup attrs ──
      function fireViewItem() {
        try {
          var node = d.querySelector('.t-store__prod-popup__container, .t-store__prod-popup, .t-store__card');
          if (!node) return;
          var id   = node.getAttribute('data-product-lid') || node.getAttribute('data-product-id') || node.getAttribute('id');
          var name = node.getAttribute('data-product-name') || (node.querySelector('.t-store__prod-popup__name, .t-store__card__title') || {}).textContent || '';
          var price = money(node.getAttribute('data-product-price') ||
                            (node.querySelector('[data-product-price-def-actual]') || {}).textContent ||
                            (node.querySelector('.t-store__prod-popup__price-wrapper, .t-store__card__price') || {}).textContent);
          if (!id) return;
          if (!once('tc_view_item_' + id)) return;
          push('view_item', String(id), {
            ecommerce: {
              currency: (w.tcart && w.tcart.currency) || 'USD',
              value:    price,
              items: [{ item_id: String(id), item_name: String(name).trim(), price: price, quantity: 1 }]
            }
          });
        } catch (e) {}
      }
    
      function fireViewItemList() {
        try {
          var cards = d.querySelectorAll('.t-store__card');
          if (!cards.length) return;
          if (!once('tc_view_item_list_' + location.pathname)) return;
          var items = [];
          for (var i = 0; i < Math.min(cards.length, 25); i++) {
            var c = cards[i];
            var id = c.getAttribute('data-product-lid') || c.getAttribute('data-product-id');
            if (!id) continue;
            items.push({
              item_id:   String(id),
              item_name: c.getAttribute('data-product-name') || (c.querySelector('.t-store__card__title') || {}).textContent || '',
              price:     money(c.getAttribute('data-product-price') || (c.querySelector('.t-store__card__price') || {}).textContent),
              index:     i
            });
          }
          if (!items.length) return;
          push('view_item_list', location.pathname, {
            ecommerce: { item_list_id: location.pathname, item_list_name: location.pathname, items: items }
          });
        } catch (e) {}
      }
    
      // ── Cart diff — watch localStorage 'tcart' for changes ──
      var prevCart = readTcart() || { products: [] };
      function diffAndFire() {
        try {
          var nc = readTcart();
          if (!nc) return;
          var oldMap = {}, newMap = {};
          (prevCart.products || []).forEach(function (p) {
            var k = String(p.uid || p.name);
            oldMap[k] = (oldMap[k] || 0) + (Number(p.quantity) || 1);
          });
          (nc.products || []).forEach(function (p) {
            var k = String(p.uid || p.name);
            newMap[k] = (newMap[k] || 0) + (Number(p.quantity) || 1);
          });
          Object.keys(newMap).forEach(function (k) {
            var d = newMap[k] - (oldMap[k] || 0);
            if (d > 0) {
              var p = (nc.products || []).filter(function (x) { return String(x.uid || x.name) === k; })[0];
              if (!p) return;
              var item = tildaItem(p); item.quantity = d;
              push('add_to_cart', k + '.' + Date.now(), {
                ecommerce: { currency: nc.currency || 'USD', value: item.price * d, items: [item] }
              });
            }
          });
          Object.keys(oldMap).forEach(function (k) {
            var d = (oldMap[k] || 0) - (newMap[k] || 0);
            if (d > 0) {
              var p = (prevCart.products || []).filter(function (x) { return String(x.uid || x.name) === k; })[0];
              if (!p) return;
              var item = tildaItem(p); item.quantity = d;
              push('remove_from_cart', k + '.' + Date.now(), {
                ecommerce: { currency: prevCart.currency || 'USD', value: item.price * d, items: [item] }
              });
            }
          });
          prevCart = nc;
        } catch (e) {}
      }
      // Tilda doesn't dispatch storage events for same-tab writes, so poll.
      setInterval(diffAndFire, 1000);
      // Cross-tab also covered via the native storage event.
      w.addEventListener('storage', function (e) { if (e && e.key === 'tcart') diffAndFire(); });
    
      function fireViewCart() {
        try {
          var c = readTcart();
          if (!c || !(c.products || []).length) return;
          var key = 'cart.' + (c.products || []).length;
          if (!once('tc_view_cart_' + key)) return;
          var items = (c.products || []).map(function (p, i) { return tildaItem(p, i); });
          var total = Number(c.total) || items.reduce(function (s, x) { return s + (x.price || 0) * (x.quantity || 1); }, 0);
          push('view_cart', key, {
            ecommerce: { currency: c.currency || 'USD', value: total, items: items }
          });
        } catch (e) {}
      }
      // Hook cart-open click handler.
      d.addEventListener('click', function (e) {
        var t = e.target && e.target.closest && e.target.closest('.t706__carticon, .t-store__card__btn, .js-product-controls .t-btn');
        if (t) setTimeout(fireViewCart, 300);
      }, true);
    
      function firePurchase() {
        try {
          if (w.tcOrder && w.tcOrder.orderId) { w.tcFirePurchase(w.tcOrder); return; }
          // Tilda Order success page may carry order id in URL or DOM.
          var u; try { u = new URL(location.href); } catch (e) { u = null; }
          var orderId = (u && (u.searchParams.get('orderid') || u.searchParams.get('order_id'))) ||
                        (d.querySelector('[data-order-id]') ? d.querySelector('[data-order-id]').getAttribute('data-order-id') : '') ||
                        ('tilda.' + Date.now());
          if (!once('tc_purchase_' + orderId)) return;
          // Best-effort: read last known cart from tcart (cleared after order, but we cached prevCart above).
          var c = prevCart && prevCart.products && prevCart.products.length ? prevCart : readTcart();
          var items = c && c.products ? c.products.map(function (p, i) { return tildaItem(p, i); }) : [];
          var total = (c && Number(c.total)) || items.reduce(function (s, x) { return s + (x.price || 0) * (x.quantity || 1); }, 0);
          push('purchase', String(orderId), {
            ecommerce: {
              transaction_id: String(orderId),
              affiliation:    'Tilda',
              value:          total,
              currency:       (c && c.currency) || 'USD',
              items:          items
            }
          });
        } catch (e) {}
      }
    
      function boot() {
        var t = pageType();
        if (t === 'product')   fireViewItem();
        if (t === 'category')  fireViewItemList();
        if (t === 'thank-you') firePurchase();
      }
      if (d.readyState === 'loading') d.addEventListener('DOMContentLoaded', boot);
      else boot();
    })(window, document);
    </script>
    <!-- End Traksolv Tilda DataLayer -->
    
    <!-- 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 -->
  5. 5

    Save and republish the site

    Save

    Save → Publish all pages (top-right) → reload your storefront

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.

FAQ

Server-side tracking for Tilda, answered

Does server-side tracking work with Tilda?

Yes. TrakSolv works with Tilda via a lightweight loader snippet plus a Tilda-specific dataLayer that fires every GA4 enhanced-ecommerce event. You paste it once in Tilda's custom-code area and conversions start flowing through your own server-side GTM container.

How do I install TrakSolv on Tilda?

Add the TrakSolv loader (head + body) and the Tilda dataLayer snippet to your store's custom-code settings, then save. The full step-by-step is on this page. Most Tilda merchants are live in a few minutes — no developer required.

What can I track server-side on Tilda?

Page views, product views, leads and purchases, 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 Tilda 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 Tilda conversions — start free.

Spin up a first-party server-side GTM container for Tilda and watch your match quality climb. No credit card, live in minutes.

WhatsApp
Server-Side Tracking for Tilda — TrakSolv | Traksolv