Taboola Cross-Domain Tracking | Blue Frog Docs

Taboola Cross-Domain Tracking

Configure Taboola Pixel to track users seamlessly across multiple domains and subdomains for accurate attribution and conversion tracking.

This guide covers implementing cross-domain tracking with Taboola to maintain user sessions and attribution across multiple websites or subdomains.

Cross-Domain Tracking Overview

Cross-domain tracking allows you to:

  • Track users across multiple domains
  • Maintain consistent user identification
  • Preserve attribution data across domain transitions
  • Accurately measure multi-domain conversion funnels
  • Build unified audiences across properties

When to Use Cross-Domain Tracking

Common Scenarios

Multi-Domain E-commerce:

  • Main site: example.com
  • Checkout: checkout.example.com or secure-checkout.com
  • Blog: blog.example.com

Separate Marketing and Transaction Sites:

  • Marketing: marketing.example.com
  • Store: store.example.com
  • Support: support.example.com

Multiple Brand Sites:

  • Brand A: brand-a.com
  • Brand B: brand-b.com
  • Parent company: parent-company.com

Basic Cross-Domain Setup

Step 1: Install Pixel on All Domains

Install the same Taboola Pixel code on all domains you want to track:

Domain 1 (example.com):

<script type="text/javascript">
  window._tfa = window._tfa || [];
  window._tfa.push({notify: 'event', name: 'page_view', id: 1234567});
  !function (t, f, a, x) {
    if (!document.getElementById(x)) {
      t.async = 1;t.src = a;t.id=x;f.parentNode.insertBefore(t, f);
    }
  }(document.createElement('script'),
  document.getElementsByTagName('script')[0],
  '//cdn.taboola.com/libtrc/unip/1234567/tfa.js',
  'tb_tfa_script');
</script>

Domain 2 (checkout.example.com):

<script type="text/javascript">
  window._tfa = window._tfa || [];
  window._tfa.push({notify: 'event', name: 'page_view', id: 1234567});
  !function (t, f, a, x) {
    if (!document.getElementById(x)) {
      t.async = 1;t.src = a;t.id=x;f.parentNode.insertBefore(t, f);
    }
  }(document.createElement('script'),
  document.getElementsByTagName('script')[0],
  '//cdn.taboola.com/libtrc/unip/1234567/tfa.js',
  'tb_tfa_script');
</script>

Important: Use the same Account ID (1234567) on all domains.

Taboola automatically handles cross-domain tracking through cookies. For subdomains of the same parent domain (e.g., www.example.com and checkout.example.com), cookies are shared automatically.

Cross-Subdomain Tracking

Automatic Subdomain Tracking

For subdomains under the same parent domain, Taboola handles tracking automatically:

Example Subdomains:

  • www.example.com
  • shop.example.com
  • checkout.example.com
  • blog.example.com

Implementation: Simply install the same pixel code on each subdomain. No additional configuration needed.

<!-- Same code on all subdomains -->
<script type="text/javascript">
  window._tfa = window._tfa || [];
  window._tfa.push({notify: 'event', name: 'page_view', id: 1234567});
  !function (t, f, a, x) {
    if (!document.getElementById(x)) {
      t.async = 1;t.src = a;t.id=x;f.parentNode.insertBefore(t, f);
    }
  }(document.createElement('script'),
  document.getElementsByTagName('script')[0],
  '//cdn.taboola.com/libtrc/unip/1234567/tfa.js',
  'tb_tfa_script');
</script>

Multiple Top-Level Domains

User ID Tracking Across Domains

For tracking across completely different domains (e.g., example.com to checkout-site.com), use user identification:

// On both domains
if (userId) {
  window._tfa.push({
    notify: 'action',
    name: 'user_id',
    id: 1234567,
    user_id: userId
  });
}

URL Parameter Passing

Pass user identification through URL parameters when linking between domains:

Domain 1 (example.com) - Outbound Link:

function generateCrossDomainUrl(baseUrl) {
  const userId = getCurrentUserId(); // Your function to get user ID
  const params = new URLSearchParams();

  if (userId) {
    params.append('user_id', userId);
  }

  return `${baseUrl}?${params.toString()}`;
}

// Usage
const checkoutUrl = generateCrossDomainUrl('https://checkout-site.com/cart');
window.location.href = checkoutUrl;

Domain 2 (checkout-site.com) - Inbound Handling:

// Extract user ID from URL
const urlParams = new URLSearchParams(window.location.search);
const userId = urlParams.get('user_id');

if (userId) {
  // Track with user ID
  window._tfa.push({
    notify: 'action',
    name: 'user_id',
    id: 1234567,
    user_id: userId
  });

  // Store for future use
  sessionStorage.setItem('user_id', userId);
}

Advanced Cross-Domain Tracking

Session ID Tracking

Maintain session continuity across domains:

// Generate or retrieve session ID
function getOrCreateSessionId() {
  let sessionId = sessionStorage.getItem('taboola_session_id');

  if (!sessionId) {
    sessionId = 'session_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
    sessionStorage.setItem('taboola_session_id', sessionId);
  }

  return sessionId;
}

// Pass session ID across domains
function addCrossDomainParams(url) {
  const sessionId = getOrCreateSessionId();
  const separator = url.includes('?') ? '&' : '?';
  return `${url}${separator}tb_session=${encodeURIComponent(sessionId)}`;
}

// Apply to all cross-domain links
document.querySelectorAll('a[href*="checkout-domain.com"]').forEach(link => {
  link.href = addCrossDomainParams(link.href);
});

On destination domain:

// Retrieve and store session ID
const urlParams = new URLSearchParams(window.location.search);
const sessionId = urlParams.get('tb_session');

if (sessionId) {
  sessionStorage.setItem('taboola_session_id', sessionId);
}

Share first-party cookies across domains using server-side synchronization:

Domain 1 - Set Cookie:

// After user identification
fetch('https://api.yoursite.com/sync-user', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    userId: userId,
    domain: 'example.com'
  })
});

Domain 2 - Retrieve Cookie:

// On page load
fetch('https://api.yoursite.com/get-user')
  .then(response => response.json())
  .then(data => {
    if (data.userId) {
      window._tfa.push({
        notify: 'action',
        name: 'user_id',
        id: 1234567,
        user_id: data.userId
      });
    }
  });

E-commerce Cross-Domain Example

Main Site to Checkout Flow

Main Site (store.example.com):

// Product page - track view
window._tfa = window._tfa || [];
window._tfa.push({
  notify: 'event',
  name: 'view_content',
  id: 1234567,
  content_id: 'PROD_123',
  value: 99.99
});

// Add to cart
function addToCart(productId, price) {
  window._tfa.push({
    notify: 'event',
    name: 'add_to_cart',
    id: 1234567,
    content_id: productId,
    value: price,
    currency: 'USD'
  });
}

// Proceed to checkout - pass cart data
function goToCheckout() {
  const cartData = {
    items: getCartItems(),
    total: getCartTotal(),
    sessionId: getOrCreateSessionId()
  };

  // Store in sessionStorage
  sessionStorage.setItem('cart_data', JSON.stringify(cartData));

  // Navigate to checkout domain with session ID
  const checkoutUrl = `https://checkout.example.com?session=${cartData.sessionId}`;
  window.location.href = checkoutUrl;
}

Checkout Site (checkout.example.com):

// Load Taboola Pixel
window._tfa = window._tfa || [];
window._tfa.push({notify: 'event', name: 'page_view', id: 1234567});

// Retrieve session from URL
const urlParams = new URLSearchParams(window.location.search);
const sessionId = urlParams.get('session');

if (sessionId) {
  sessionStorage.setItem('taboola_session_id', sessionId);

  // Track checkout initiation
  window._tfa.push({
    notify: 'event',
    name: 'custom',
    id: 1234567,
    custom_event_name: 'checkout_initiated'
  });
}

// Track purchase
function trackPurchase(orderId, total) {
  window._tfa.push({
    notify: 'event',
    name: 'make_purchase',
    id: 1234567,
    revenue: total,
    currency: 'USD',
    order_id: orderId
  });
}

Testing Cross-Domain Tracking

Manual Testing

  1. Start on Domain 1:

    • Visit www.example.com
    • Open browser console
    • Note the Taboola cookie values
  2. Navigate to Domain 2:

    • Click link to checkout.example.com
    • Check if user tracking continues
    • Verify events fire correctly
  3. Verify User ID:

    // On both domains
    console.log('User ID:', sessionStorage.getItem('user_id'));
    

Automated Testing

// Test cross-domain link decoration
function testCrossDomainLinks() {
  const links = document.querySelectorAll('a[href*="checkout"]');

  links.forEach(link => {
    const url = new URL(link.href);
    const hasSessionParam = url.searchParams.has('tb_session') ||
                           url.searchParams.has('user_id');

    console.log(`Link: ${link.href}`);
    console.log(`Has tracking params: ${hasSessionParam}`);
  });
}

testCrossDomainLinks();

Conversion Attribution Across Domains

Track Full Funnel

Domain 1 - Marketing Site:

// Track initial engagement
window._tfa.push({
  notify: 'event',
  name: 'custom',
  id: 1234567,
  custom_event_name: 'product_interest',
  content_id: productId
});

Domain 2 - E-commerce Site:

// Track add to cart
window._tfa.push({
  notify: 'event',
  name: 'add_to_cart',
  id: 1234567,
  content_id: productId,
  value: price,
  currency: 'USD'
});

Domain 3 - Checkout Domain:

// Track conversion
window._tfa.push({
  notify: 'event',
  name: 'make_purchase',
  id: 1234567,
  revenue: total,
  currency: 'USD',
  order_id: orderId
});

Privacy Considerations

GDPR Compliance

// Check consent before cross-domain tracking
function initCrossDomainTracking() {
  if (hasMarketingConsent()) {
    const userId = getCurrentUserId();

    if (userId) {
      window._tfa.push({
        notify: 'action',
        name: 'user_id',
        id: 1234567,
        user_id: userId
      });
    }
  }
}

// Wait for consent
window.addEventListener('consent_updated', function(e) {
  if (e.detail.marketing === true) {
    initCrossDomainTracking();
  }
});

Anonymize Cross-Domain Data

// Hash user identifiers
async function hashUserId(userId) {
  const msgBuffer = new TextEncoder().encode(userId.toString());
  const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
  const hashArray = Array.from(new Uint8Array(hashBuffer));
  return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
}

// Use hashed ID for cross-domain tracking
const hashedUserId = await hashUserId(userId);

window._tfa.push({
  notify: 'action',
  name: 'user_id',
  id: 1234567,
  user_id: hashedUserId
});

Troubleshooting Cross-Domain Tracking

Issue: User ID Not Persisting

Check:

  1. Verify same account ID used on all domains
  2. Ensure user_id event fires on all domains
  3. Check sessionStorage/localStorage is accessible
  4. Verify URL parameters are passed correctly

Debug:

// On each domain
console.log('Account ID:', 1234567);
console.log('User ID:', sessionStorage.getItem('user_id'));
console.log('Session ID:', sessionStorage.getItem('taboola_session_id'));

Issue: Conversions Not Attributed

Check:

  1. User tracking continues across domains
  2. Same Taboola account used
  3. Conversion event fires correctly
  4. No cookie blocking between domains

Debug:

// Track domain transitions
window.addEventListener('load', function() {
  console.log('Current domain:', window.location.hostname);
  console.log('Referrer:', document.referrer);
  console.log('Taboola events:', window._tfa);
});

Solution: Use first-party user identification:

// Don't rely solely on cookies
// Use user_id for cross-domain tracking
function ensureCrossDomainTracking() {
  const userId = getUserIdFromSession() || getUserIdFromUrl();

  if (userId) {
    window._tfa.push({
      notify: 'action',
      name: 'user_id',
      id: 1234567,
      user_id: userId
    });

    // Store for future use
    sessionStorage.setItem('user_id', userId);
  }
}

Best Practices

  1. Consistent Account ID - Use same Taboola account ID across all domains
  2. User Identification - Implement reliable user ID tracking
  3. URL Parameters - Pass tracking parameters in cross-domain links
  4. Session Management - Maintain session continuity across domains
  5. Privacy Compliance - Respect user consent across all domains
  6. Testing - Thoroughly test cross-domain flows
  7. Documentation - Document all cross-domain relationships

Next Steps

// SYS.FOOTER