Woopra Cross-Domain Tracking | OpsBlu Docs

Woopra Cross-Domain Tracking

How to track users across multiple domains and subdomains with Woopra. Covers cross-domain configuration, cookie handling, session stitching, and.

Overview

Cross-domain tracking in Woopra allows you to follow user journeys across multiple domains and subdomains. This is essential for businesses with multiple properties (marketing site, app, blog, etc.) that want to maintain a unified view of user behavior.

How It Works

Woopra uses consistent user identification to merge sessions across domains. When you identify a user with the same identifier on different domains, Woopra automatically links their sessions together.

Key Concepts

  • Visitor ID: A unique identifier for each user that persists across domains
  • Session Merging: When the same visitor ID is used on multiple domains, Woopra merges the sessions
  • Identity Persistence: User identities are maintained in cookies and local storage

Implementation

Basic Setup

Use woopra.identify() with the same user identifier on all domains:

// On all domains (e.g., example.com, app.example.com, blog.example.com)
woopra.identify({
  email: 'user@example.com'
});
woopra.track();

Using Custom User IDs

For better control, use your own user IDs instead of email addresses:

// Identify user with consistent ID across domains
woopra.identify({
  id: 'user_12345',
  email: 'user@example.com',
  name: 'John Doe'
});
woopra.track();

Tracking Domain Changes

Track when users navigate between domains:

// Track domain transition events
woopra.track('domain_change', {
  from_domain: document.referrer,
  to_domain: window.location.hostname
});

Configuration

Configure cookie domain to work across subdomains:

woopra.config({
  domain: '.example.com',  // Leading dot allows all subdomains
  cookie_domain: '.example.com',
  cookie_path: '/',
  cookie_expire: 31536000  // 1 year in seconds
});

Subdomain Tracking

For tracking across subdomains (e.g., www.example.com, app.example.com):

// On www.example.com
woopra.config({
  domain: 'example.com',
  cookie_domain: '.example.com'
});
woopra.identify({ email: 'user@example.com' });
woopra.track();

// On app.example.com (same configuration)
woopra.config({
  domain: 'example.com',
  cookie_domain: '.example.com'
});
woopra.identify({ email: 'user@example.com' });
woopra.track();

Multiple Root Domains

For separate root domains (e.g., example.com and example.co.uk):

// Use the same identification logic on both domains
const userId = getUserIdFromYourSystem();

// On example.com
woopra.config({ domain: 'example.com' });
woopra.identify({
  id: userId,
  email: 'user@example.com'
});

// On example.co.uk
woopra.config({ domain: 'example.co.uk' });
woopra.identify({
  id: userId,
  email: 'user@example.com'
});

Best Practices

Consistent Identification

Always use the same identification method across all domains:

// Good - consistent user ID
woopra.identify({ id: 'user_12345' });

// Avoid - different identifiers on different domains
// Domain A: woopra.identify({ email: 'user@example.com' });
// Domain B: woopra.identify({ id: 'user_12345' });

Identify Early

Call woopra.identify() as early as possible on each page:

// In your site header, after Woopra loads
if (typeof woopra !== 'undefined' && userIsLoggedIn) {
  woopra.identify({
    id: currentUser.id,
    email: currentUser.email
  });
}

Handle Anonymous Users

For users who aren't logged in, Woopra automatically assigns a visitor ID:

// Logged out users - Woopra handles automatically
woopra.track();  // Uses anonymous visitor ID

// When user logs in - identify them
woopra.identify({
  id: 'user_12345',
  email: 'user@example.com'
});

Troubleshooting

Sessions Not Merging

If sessions aren't merging across domains:

  1. Verify consistent IDs: Check that you're using the same identifier on all domains
  2. Check cookie settings: Ensure cookies are being set correctly
  3. Verify timing: Make sure woopra.identify() is called before woopra.track()
// Debug mode to see what's happening
woopra.config({ debug: true });
woopra.identify({ email: 'test@example.com' });
woopra.track();
// Check browser console for Woopra debug messages

If cookies aren't persisting across domains:

// Check current cookie configuration
console.log(woopra.config());

// Verify cookie domain setting
woopra.config({
  cookie_domain: '.example.com',
  cookie_path: '/'
});

Testing Cross-Domain Tracking

Test your cross-domain tracking:

  1. Visit Domain A and identify yourself
  2. Navigate to Domain B
  3. Identify with the same credentials
  4. Check Woopra dashboard to verify sessions are merged