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.
<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:
| Event | Description |
|---|---|
page_view | Every page load |
link_click | Link clicks (including outbound) |
form_submit | Form submissions |
Custom Event Tracking
Use the smp() function to track custom events.
// Track a custom event
smp('track', 'event_name', { properties });Examples
// 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-trackAutomatically track clicks on this element.
<button data-smp-track="signup_clicked">Sign Up</button>data-smp-track-*Add custom properties to the tracked event.
<button
data-smp-track="button_clicked"
data-smp-track-button-id="cta-main"
data-smp-track-variant="blue"
>
Get Started
</button>data-smp-ignoreExclude this element from automatic tracking.
<a href="/internal-page" data-smp-ignore>Skip tracking</a>Subscriber Identification
Connect anonymous visitor data to known subscribers using the identify method.
// 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
// 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 visitorAPI Management
Create and manage tracking pixels programmatically using the API or SDK.
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
{
"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.
// Disable tracking (e.g., if user declines cookies)
smp('optOut');
// Re-enable tracking
smp('optIn');
// Check current status
const isOptedOut = smp('isOptedOut');