Documentation

Quick Start

1. Get Your Site ID

Sign up and create a site in the dashboard. You will get a unique trackingId as your data-site-id.

2. Add the Tracking Snippet

Add this to your website's <head> tag:

<script src="https://trailpixel.com/tracker.js" data-site-id="YOUR_SITE_ID"></script>

Page views and clicks are now tracked automatically.

Track Custom Events

After the script loads, window.trailpixel (or window.tp) is available globally:

// Track a lead/signup
window.trailpixel.track('lead', {
  name: 'Lead Generated',
  properties: { source: 'newsletter_form' }
})

// Track a purchase
window.trailpixel.track('purchase', {
  name: 'Purchase Completed',
  properties: { amount: 49, currency: 'EUR', product: 'Pro Plan' }
})

// Track any custom event
window.trailpixel.track('custom', {
  name: 'Video Watched',
  category: 'engagement',
  properties: { duration: 120, videoId: 'abc123' }
})

Identify Users

Link anonymous visitors to known users for cross-session tracking:

// After login/signup
window.trailpixel.identify({
  email: 'user@example.com',
  name: 'John Doe'
})

Cookieless & GDPR

TrailPixel uses localStorage to store a unique visitor ID — not cookies. Under GDPR Article 5(3) and ePrivacy Directive, localStorage used for functionality (not advertising/tracking purposes) does not require cookie consent.

  • Randomly generated UUID
  • Stored only in the user's browser localStorage
  • Never shared with third parties
  • Not used for ad targeting

Data-tp-name for Click Tracking

Use the data-tp-name attribute to give meaningful names to tracked clicks:

<button data-tp-name="Signup CTA Button">Get Started</button>
<a href="/pricing" data-tp-name="Nav Pricing Link">Pricing</a>

A/B Testing

Create an A/B test in the dashboard, then use the variant assignment:

// On your server, assign a variant
const variantId = Math.random() < 0.5 ? 'variant_a' : 'variant_b'

// Track which variant the visitor saw
window.trailpixel.track('custom', {
  name: 'Variant Seen',
  properties: { testId: 'YOUR_TEST_ID', variant: variantId }
})

// TrailPixel automatically correlates this with downstream funnel events