Docs/Pixel Tracking

Pixel Tracking

Track website visitor behavior and connect it to your email campaigns.

The SendMailOS tracking pixel monitors visitor activity on your website and attributes conversions to your email campaigns. This enables powerful analytics and automated workflows based on user behavior.

Page Views

Automatic tracking of all page loads with UTM parameters

Click Tracking

Monitor link clicks and button interactions

Identity Linking

Connect anonymous visitors to email subscribers

Installation

Add the tracking pixel to your website by including the script in your HTML <head> section.

html
<script src="https://sendmailos.com/pixel.js" data-key="pk_live_your_public_key"></script>

Automatic Tracking

Once installed, the pixel automatically tracks the following events without additional configuration:

EventDescription
page_viewEvery page load
link_clickLink clicks (including outbound)
form_submitForm submissions

Custom Event Tracking

Use the smp() function to track custom events.

javascript
// Track a custom event
smp('track', 'event_name', { properties });

Examples

javascript
// Track a button click
smp('track', 'button_click', {
  button_id: 'cta-signup',
  button_text: 'Get Started'
});

// Track a video play
smp('track', 'video_played', {
  video_id: 'intro-video',
  duration: 120
});

// Track a file download
smp('track', 'file_downloaded', {
  file_name: 'whitepaper.pdf',
  file_type: 'pdf'
});

Data Attributes

Use HTML data attributes to track events without writing JavaScript.

data-smp-track

Automatically track clicks on this element.

html
<button data-smp-track="signup_clicked">Sign Up</button>
data-smp-track-*

Add custom properties to the tracked event.

html
<button
  data-smp-track="button_clicked"
  data-smp-track-button-id="cta-main"
  data-smp-track-variant="blue"
>
  Get Started
</button>
data-smp-ignore

Exclude this element from automatic tracking.

html
<a href="/internal-page" data-smp-ignore>Skip tracking</a>

Subscriber Identification

Connect anonymous visitor data to known subscribers using the identify method.

javascript
// Identify a subscriber by email
smp('identify', '[email protected]');

// Identify with additional traits
smp('identify', '[email protected]', {
  first_name: 'John',
  last_name: 'Doe',
  plan: 'professional',
  company: 'Acme Inc'
});

Best Practice

Call identify after login or form submission to link browsing history to subscriber profiles.

Common Integration Points

javascript
// After login
function onLoginSuccess(user) {
  smp('identify', user.email, {
    user_id: user.id,
    created_at: user.createdAt
  });
}

// After newsletter signup
form.addEventListener('submit', (e) => {
  const email = form.querySelector('[name="email"]').value;
  smp('identify', email);
  smp('track', 'newsletter_subscribed');
});

// From email link click (auto-identified)
// Links in emails include ?smp_sub=subscriber_id
// The pixel automatically identifies the visitor

API Management

Create and manage tracking pixels programmatically using the API or SDK.

typescript
import { SendMailOS } from '@sendmailos/sdk';

const client = new SendMailOS('sk_live_your_api_key');

// Create a pixel
const { pixel } = await client.pixels.create({
  name: 'Main Website',
  domain: 'example.com'
});
console.log('Pixel token:', pixel.token);

// List all pixels
const { pixels } = await client.pixels.list();

// List pixels for a specific domain (agency accounts)
const { pixels: clientPixels } = await client.pixels.list({
  domain: 'client.com'
});

Create Pixel Response

json
{
  "success": true,
  "pixel": {
    "id": "pxl_abc123",
    "name": "Main Website",
    "domain": "example.com",
    "token": "pk_live_abc123def456",
    "active": true,
    "workspace_id": "ws_xyz789",
    "created_at": "2024-01-15T10:30:00Z"
  }
}

Privacy & Consent

The SendMailOS pixel is designed with privacy in mind.

No third-party cookies - first-party context only
Form input values are never captured automatically
Respects Do Not Track (DNT) browser settings
Compatible with cookie consent management
javascript
// Disable tracking (e.g., if user declines cookies)
smp('optOut');

// Re-enable tracking
smp('optIn');

// Check current status
const isOptedOut = smp('isOptedOut');

Related Resources