Event Tracking Setup
Implement DAS Pixel for eCommerce tracking and user activity collection
Event Tracking Setup
Ring DAS Pixel enables comprehensive eCommerce tracking and user activity collection. This guide shows you how to integrate the pixel, track events, manage sessions, and ensure GDPR compliance.
What is DAS Pixel?
DAS Pixel is Ring DAS's activity tracking module that:
- Tracks eCommerce events: Product views, cart actions, purchases
- Identifies users: Anonymous (LU) and logged-in (AID) tracking
- Manages sessions: Automatic session lifecycle tracking
- Feeds ML models: Provides data for ad decisioning and optimization
- Enables attribution: Links ad impressions to conversions
DAS Pixel vs. Audience: DAS Pixel is a separate module that collects raw event data. The Audience module consumes this data to build user segments for targeting.
Quick Start
Step 1: Embed Tracking Script
Add the DAS Pixel script to all pages of your website:
<!DOCTYPE html>
<html>
<head>
<!-- Add to <head> section -->
<script async src="https://pixel.ringdas.com/v1/pixel.js"></script>
<script>
// Initialize DAS Pixel
window.dlApi = window.dlApi || { cmd: [] };
dlApi.cmd.push(function(dlApi) {
dlApi.init({
network: 'YOUR_NETWORK_ID', // Your Ring DAS network ID
pixelId: 'YOUR_PIXEL_ID', // Your pixel ID
enableAutomaticTracking: true // Auto-track page views
});
});
</script>
</head>
<body>
<!-- Your page content -->
</body>
</html>Step 2: Track Page Views
Page views are tracked automatically when enableAutomaticTracking: true. To track manually:
dlApi.cmd.push(function(dlApi) {
dlApi.sendActivityEvent({
network: 'YOUR_NETWORK_ID',
event: 'page_view',
actgid: 'YOUR_PIXEL_ID'
});
});Step 3: Track Product Views
When a user views a product:
dlApi.cmd.push(function(dlApi) {
dlApi.sendActivityEvent({
network: 'YOUR_NETWORK_ID',
event: 'product_detail',
actgid: 'YOUR_PIXEL_ID',
// Product information
products: [
{
id: 'SKU-12345',
name: 'Wireless Headphones',
price: '99.99',
brand: 'AudioTech',
category: 'Electronics/Audio',
variant: 'Black',
qty: '1'
}
]
});
});Step 4: Track Purchases
When a purchase is completed:
dlApi.cmd.push(function(dlApi) {
dlApi.sendActivityEvent({
network: 'YOUR_NETWORK_ID',
event: 'purchased',
actgid: 'YOUR_PIXEL_ID',
// Transaction details
ord: 'ORDER-2024-001', // Order ID
cost: '249.97', // Total order value
tax: '24.99', // Tax amount
shipping: '9.99', // Shipping cost
// Products purchased
products: [
{
id: 'SKU-12345',
name: 'Wireless Headphones',
price: '99.99',
brand: 'AudioTech',
category: 'Electronics/Audio',
variant: 'Black',
qty: '1'
},
{
id: 'SKU-67890',
name: 'Phone Case',
price: '19.99',
brand: 'ProtectPlus',
category: 'Accessories',
variant: 'Blue',
qty: '2'
}
]
});
});JavaScript SDK Setup
Installation Methods
Method 1: Async Script Tag (Recommended)
<script async src="https://pixel.ringdas.com/v1/pixel.js"></script>
<script>
window.dlApi = window.dlApi || { cmd: [] };
</script>Advantages:
- Non-blocking page load
- Better performance
- Recommended for production
Method 2: NPM Package
npm install @ringdas/pixelimport { DASPixel } from '@ringdas/pixel';
const pixel = new DASPixel({
network: 'YOUR_NETWORK_ID',
pixelId: 'YOUR_PIXEL_ID',
enableAutomaticTracking: true
});
// Track event
pixel.trackEvent('product_detail', {
products: [{ id: 'SKU-123', name: 'Product' }]
});Configuration Options
dlApi.cmd.push(function(dlApi) {
dlApi.init({
// Required
network: 'YOUR_NETWORK_ID',
pixelId: 'YOUR_PIXEL_ID',
// Optional
enableAutomaticTracking: true, // Auto-track page views
enableSessionTracking: true, // Auto-manage sessions
enableScrollTracking: false, // Track scroll depth
enableClickTracking: false, // Track link clicks
// Session configuration
sessionTimeout: 1800, // Session timeout (seconds)
cookieDomain: '.example.com', // Cookie domain
cookiePath: '/', // Cookie path
cookieSecure: true, // HTTPS only cookies
cookieSameSite: 'Lax', // SameSite policy
// Privacy
respectDoNotTrack: true, // Honor DNT header
anonymizeIp: false, // Anonymize IP addresses
// Debug
debug: false // Enable debug logging
});
});Tracking eCommerce Events
Event Type Reference
DAS Pixel supports these eCommerce events:
| Event | Description | When to Fire |
|---|---|---|
page_view | Page view | On every page load |
product_detail | Product page view | When user views product |
add_to_cart | Add product to cart | When item added to cart |
remove_from_cart | Remove from cart | When item removed from cart |
view_cart | View shopping cart | When cart page is viewed |
checkout | Begin checkout | When checkout starts |
purchased | Purchase complete | After order confirmation |
search_query | Search performed | When user searches |
custom | Custom event | Your custom tracking needs |
Product Detail Event
Track when users view products:
dlApi.cmd.push(function(dlApi) {
dlApi.sendActivityEvent({
network: 'YOUR_NETWORK_ID',
event: 'product_detail',
actgid: 'YOUR_PIXEL_ID',
products: [
{
id: 'SKU-12345', // Required: Product SKU
name: 'Product Name', // Required: Product name
price: '99.99', // Required: Price
brand: 'Brand Name', // Recommended: Brand
category: 'Cat/Subcat', // Recommended: Category path
variant: 'Color/Size', // Optional: Variant
qty: '1', // Optional: Quantity viewed
position: '1', // Optional: Position in list
list: 'Search Results' // Optional: Source list
}
]
});
});Add to Cart Event
Track cart additions:
// Single product
dlApi.cmd.push(function(dlApi) {
dlApi.sendActivityEvent({
network: 'YOUR_NETWORK_ID',
event: 'add_to_cart',
actgid: 'YOUR_PIXEL_ID',
products: [
{
id: 'SKU-12345',
name: 'Wireless Headphones',
price: '99.99',
brand: 'AudioTech',
category: 'Electronics/Audio',
variant: 'Black',
qty: '1'
}
]
});
});
// Multiple products (bulk add)
dlApi.cmd.push(function(dlApi) {
dlApi.sendActivityEvent({
network: 'YOUR_NETWORK_ID',
event: 'add_to_cart',
actgid: 'YOUR_PIXEL_ID',
products: [
{ id: 'SKU-12345', name: 'Item 1', price: '99.99', qty: '1' },
{ id: 'SKU-67890', name: 'Item 2', price: '49.99', qty: '2' }
]
});
});Remove from Cart Event
Track cart removals:
dlApi.cmd.push(function(dlApi) {
dlApi.sendActivityEvent({
network: 'YOUR_NETWORK_ID',
event: 'remove_from_cart',
actgid: 'YOUR_PIXEL_ID',
products: [
{
id: 'SKU-12345',
name: 'Wireless Headphones',
price: '99.99',
qty: '1'
}
]
});
});View Cart Event
Track when users view their cart:
dlApi.cmd.push(function(dlApi) {
dlApi.sendActivityEvent({
network: 'YOUR_NETWORK_ID',
event: 'view_cart',
actgid: 'YOUR_PIXEL_ID',
// Include all cart items
products: [
{
id: 'SKU-12345',
name: 'Wireless Headphones',
price: '99.99',
qty: '1'
},
{
id: 'SKU-67890',
name: 'Phone Case',
price: '19.99',
qty: '2'
}
],
// Optional: Cart value
cartValue: '139.97'
});
});Checkout Event
Track checkout initiation:
dlApi.cmd.push(function(dlApi) {
dlApi.sendActivityEvent({
network: 'YOUR_NETWORK_ID',
event: 'checkout',
actgid: 'YOUR_PIXEL_ID',
products: [
{
id: 'SKU-12345',
name: 'Wireless Headphones',
price: '99.99',
qty: '1'
}
],
// Optional: Checkout step
checkoutStep: '1', // Step number
checkoutOption: 'Guest' // Option selected
});
});Purchase Event (Conversion)
Track completed purchases:
dlApi.cmd.push(function(dlApi) {
dlApi.sendActivityEvent({
network: 'YOUR_NETWORK_ID',
event: 'purchased',
actgid: 'YOUR_PIXEL_ID',
// Required: Transaction details
ord: 'ORDER-2024-001', // Unique order ID
cost: '249.97', // Total order value
// Recommended: Additional transaction info
tax: '24.99', // Tax amount
shipping: '9.99', // Shipping cost
discount: '10.00', // Discount applied
coupon: 'SAVE10', // Coupon code used
currency: 'USD', // Currency code
// Required: Products purchased
products: [
{
id: 'SKU-12345',
name: 'Wireless Headphones',
price: '99.99',
brand: 'AudioTech',
category: 'Electronics/Audio',
variant: 'Black',
qty: '1'
},
{
id: 'SKU-67890',
name: 'Phone Case',
price: '19.99',
brand: 'ProtectPlus',
category: 'Accessories',
variant: 'Blue',
qty: '2'
}
],
// Optional: Payment method
paymentMethod: 'credit_card'
});
});Search Query Event
Track site searches:
dlApi.cmd.push(function(dlApi) {
dlApi.sendActivityEvent({
network: 'YOUR_NETWORK_ID',
event: 'search_query',
actgid: 'YOUR_PIXEL_ID',
searchTerm: 'wireless headphones', // Search query
searchResults: '42', // Number of results
searchFilters: { // Applied filters
priceRange: '50-100',
brand: 'AudioTech',
category: 'Electronics'
}
});
});Custom Events
Track custom user actions:
dlApi.cmd.push(function(dlApi) {
dlApi.sendActivityEvent({
network: 'YOUR_NETWORK_ID',
event: 'custom',
actgid: 'YOUR_PIXEL_ID',
customEventName: 'video_played', // Your event name
customData: { // Any data you want
videoId: 'video-123',
videoTitle: 'Product Demo',
duration: '120',
timestamp: Date.now()
}
});
});Session Management
Automatic Session Tracking
DAS Pixel automatically manages user sessions:
dlApi.cmd.push(function(dlApi) {
dlApi.init({
network: 'YOUR_NETWORK_ID',
pixelId: 'YOUR_PIXEL_ID',
enableSessionTracking: true, // Enable automatic sessions
sessionTimeout: 1800 // 30 minutes timeout
});
});Session Lifecycle:
- Session Start: First page view creates new session
- Session Active: Events extend session lifetime
- Session Timeout: 30 minutes of inactivity ends session
- New Session: Next activity starts new session
Manual Session Control
Override automatic session management:
// Start new session
dlApi.cmd.push(function(dlApi) {
dlApi.startSession();
});
// End current session
dlApi.cmd.push(function(dlApi) {
dlApi.endSession();
});
// Get current session ID
dlApi.cmd.push(function(dlApi) {
const sessionId = dlApi.getSessionId();
console.log('Session ID:', sessionId);
});Session Context
Add custom session context:
dlApi.cmd.push(function(dlApi) {
dlApi.setSessionContext({
campaignSource: 'google',
campaignMedium: 'cpc',
campaignName: 'summer_sale',
landingPage: '/products/special-offer',
referrer: 'https://google.com/search'
});
});User Identification
Anonymous Users (LU)
DAS Pixel automatically assigns a browser identifier (LU) via cookie:
dlApi.cmd.push(function(dlApi) {
// Get anonymous user ID
const lu = dlApi.getLU();
console.log('Browser ID:', lu); // e.g., "201905161437551994208900"
});LU Cookie Details:
- Name:
_ringdas_lu - Type: 3rd party cookie
- Lifetime: 2 years
- Format: Timestamp-based unique identifier
Logged-In Users (AID)
Identify logged-in users with AID (hashed email):
dlApi.cmd.push(function(dlApi) {
dlApi.setUserId({
aid: hashEmail('[email protected]'), // Hashed email (SHA-256)
email: '[email protected]' // Optional: plaintext for hashing
});
});
// Helper function to hash email
function hashEmail(email) {
// Use SHA-256 or your preferred hash
return CryptoJS.SHA256(email.toLowerCase().trim()).toString();
}Best Practices:
- Set user ID immediately after login
- Clear user ID on logout
- Hash emails client-side before sending
- Use consistent hashing algorithm (SHA-256)
Clear User Identity
Remove user identification (logout):
dlApi.cmd.push(function(dlApi) {
dlApi.clearUserId();
});GDPR Compliance
Consent Management
Respect user privacy preferences:
dlApi.cmd.push(function(dlApi) {
dlApi.setConsent({
analytics: true, // Analytics tracking
personalization: true, // Personalized ads
marketing: false // Marketing tracking
});
});TCF 2.2 Integration
Integrate with IAB Transparency & Consent Framework:
// Wait for CMP to be ready
window.__tcfapi('addEventListener', 2, function(tcData, success) {
if (success && tcData.eventStatus === 'useractioncomplete') {
// User made consent choice
dlApi.cmd.push(function(dlApi) {
dlApi.setConsent({
analytics: tcData.purpose.consents[1], // Purpose 1: Store/access info
personalization: tcData.purpose.consents[3], // Purpose 3: Personalized ads
marketing: tcData.purpose.consents[4], // Purpose 4: Personalized content
tcfString: tcData.tcString // Full TCF consent string
});
// Initialize pixel after consent
dlApi.init({
network: 'YOUR_NETWORK_ID',
pixelId: 'YOUR_PIXEL_ID'
});
});
}
});Do Not Track
Honor browser DNT settings:
dlApi.cmd.push(function(dlApi) {
dlApi.init({
network: 'YOUR_NETWORK_ID',
pixelId: 'YOUR_PIXEL_ID',
respectDoNotTrack: true // Don't track if DNT=1
});
});Opt-Out
Provide user opt-out functionality:
// Opt out of tracking
dlApi.cmd.push(function(dlApi) {
dlApi.optOut();
});
// Opt back in
dlApi.cmd.push(function(dlApi) {
dlApi.optIn();
});
// Check opt-out status
dlApi.cmd.push(function(dlApi) {
const isOptedOut = dlApi.isOptedOut();
console.log('User opted out:', isOptedOut);
});Data Deletion Request
Support GDPR right to be forgotten:
// Client-side: Clear user data
dlApi.cmd.push(function(dlApi) {
dlApi.deleteUserData();
});
// Server-side: Submit deletion request
fetch('https://api.ringdas.com/v1/gdpr/delete', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${API_KEY}`
},
body: JSON.stringify({
networkId: 'YOUR_NETWORK_ID',
userId: 'USER_AID_OR_LU',
deleteAll: true
})
});Implementation Examples
E-commerce Integration (Complete)
<!DOCTYPE html>
<html>
<head>
<!-- DAS Pixel -->
<script async src="https://pixel.ringdas.com/v1/pixel.js"></script>
<script>
window.dlApi = window.dlApi || { cmd: [] };
// Wait for consent before initializing
function initPixel() {
dlApi.cmd.push(function(dlApi) {
// Set consent
dlApi.setConsent({
analytics: true,
personalization: true,
marketing: true
});
// Initialize
dlApi.init({
network: 'YOUR_NETWORK_ID',
pixelId: 'YOUR_PIXEL_ID',
enableAutomaticTracking: true
});
// Identify logged-in user
const userEmail = getUserEmail(); // Your function
if (userEmail) {
dlApi.setUserId({
email: userEmail
});
}
});
}
// Initialize after consent
document.addEventListener('DOMContentLoaded', initPixel);
</script>
</head>
<body>
<!-- Product Page -->
<div id="product-detail" data-product-id="SKU-12345">
<h1>Wireless Headphones</h1>
<p>Price: $99.99</p>
<button id="add-to-cart">Add to Cart</button>
</div>
<script>
// Track product view
dlApi.cmd.push(function(dlApi) {
dlApi.sendActivityEvent({
network: 'YOUR_NETWORK_ID',
event: 'product_detail',
actgid: 'YOUR_PIXEL_ID',
products: [
{
id: 'SKU-12345',
name: 'Wireless Headphones',
price: '99.99',
brand: 'AudioTech',
category: 'Electronics/Audio',
variant: 'Black'
}
]
});
});
// Track add to cart
document.getElementById('add-to-cart').addEventListener('click', function() {
dlApi.cmd.push(function(dlApi) {
dlApi.sendActivityEvent({
network: 'YOUR_NETWORK_ID',
event: 'add_to_cart',
actgid: 'YOUR_PIXEL_ID',
products: [
{
id: 'SKU-12345',
name: 'Wireless Headphones',
price: '99.99',
qty: '1'
}
]
});
});
// Add to cart logic...
});
</script>
</body>
</html>React Integration
import React, { useEffect } from 'react';
import { useDASPixel } from '@ringdas/pixel-react';
function ProductPage({ product }) {
const pixel = useDASPixel({
network: process.env.REACT_APP_RINGDAS_NETWORK_ID,
pixelId: process.env.REACT_APP_RINGDAS_PIXEL_ID
});
useEffect(() => {
// Track product view on mount
pixel.trackEvent('product_detail', {
products: [
{
id: product.sku,
name: product.name,
price: product.price,
brand: product.brand,
category: product.category
}
]
});
}, [product, pixel]);
const handleAddToCart = () => {
// Track add to cart
pixel.trackEvent('add_to_cart', {
products: [
{
id: product.sku,
name: product.name,
price: product.price,
qty: '1'
}
]
});
// Add to cart logic...
};
return (
<div>
<h1>{product.name}</h1>
<p>${product.price}</p>
<button onClick={handleAddToCart}>Add to Cart</button>
</div>
);
}Server-Side Tracking (Node.js)
For tracking events server-side (offline conversions, backend processes):
const fetch = require('node-fetch');
async function trackServerSideEvent(event) {
const response = await fetch('https://pixel.ringdas.com/api/v1/events', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
network: process.env.RINGDAS_NETWORK_ID,
actgid: process.env.RINGDAS_PIXEL_ID,
event: event.type,
timestamp: new Date().toISOString(),
userId: event.userId,
sessionId: event.sessionId,
...event.data
})
});
return response.json();
}
// Usage: Track offline conversion
trackServerSideEvent({
type: 'purchased',
userId: 'user-aid-hash',
sessionId: 'session-123',
data: {
ord: 'ORDER-2024-001',
cost: '249.97',
products: [
{ id: 'SKU-123', name: 'Product', price: '99.99', qty: '1' }
]
}
});Debugging
Enable Debug Mode
dlApi.cmd.push(function(dlApi) {
dlApi.init({
network: 'YOUR_NETWORK_ID',
pixelId: 'YOUR_PIXEL_ID',
debug: true // Enables console logging
});
});Debug output:
[DAS Pixel] Initialized: network=YOUR_NETWORK_ID, pixel=YOUR_PIXEL_ID
[DAS Pixel] Session started: session_abc123
[DAS Pixel] Event sent: product_detail
[DAS Pixel] Response: {"status":"success","eventId":"evt_xyz789"}
Test Events
Send test events to verify integration:
dlApi.cmd.push(function(dlApi) {
// Send test event
dlApi.sendTestEvent('product_detail', {
products: [{ id: 'TEST-SKU', name: 'Test Product', price: '1.00' }]
}).then(response => {
console.log('Test event response:', response);
});
});Browser Console Inspection
Check pixel status in browser console:
// Check if pixel is loaded
console.log('Pixel loaded:', typeof dlApi !== 'undefined');
// Get session ID
dlApi.cmd.push(function(dlApi) {
console.log('Session ID:', dlApi.getSessionId());
console.log('User LU:', dlApi.getLU());
console.log('User AID:', dlApi.getAID());
});
// List all tracked events (debug mode only)
dlApi.cmd.push(function(dlApi) {
console.log('Events:', dlApi.getEventLog());
});Performance Considerations
Async Loading
Always load pixel asynchronously:
<!-- Good: Non-blocking -->
<script async src="https://pixel.ringdas.com/v1/pixel.js"></script>
<!-- Bad: Blocks page rendering -->
<script src="https://pixel.ringdas.com/v1/pixel.js"></script>Event Batching
Batch events for better performance:
dlApi.cmd.push(function(dlApi) {
// Queue multiple events
const events = [
{ event: 'page_view', actgid: 'YOUR_PIXEL_ID' },
{ event: 'product_detail', actgid: 'YOUR_PIXEL_ID', products: [...] },
{ event: 'add_to_cart', actgid: 'YOUR_PIXEL_ID', products: [...] }
];
// Send as batch
dlApi.sendEventBatch(events);
});Network Resilience
Handle network failures gracefully:
dlApi.cmd.push(function(dlApi) {
dlApi.init({
network: 'YOUR_NETWORK_ID',
pixelId: 'YOUR_PIXEL_ID',
enableOfflineQueue: true, // Queue events when offline
maxQueueSize: 100, // Max queued events
retryFailedEvents: true, // Retry failed events
maxRetries: 3 // Max retry attempts
});
});Limits and Quotas
DAS Pixel has the following limits:
| Resource | Limit | Notes |
|---|---|---|
| Activity Groups | 50,000 per network | Unique pixel IDs |
| Activities per Group | 50 | Event types per pixel |
| Daily Events | 50M per network | Total events per day |
| Ingestion Latency | ≤ 60 seconds | Event processing time |
| Event Retention | 30+ days | Minimum retention period |
| Batch Size | 100 events | Max events per batch request |
| Request Rate | 1,000 req/sec | Per network |
Need Higher Limits? Contact your account manager to request limit increases (up to 2x available upon request).
Next Steps
Validate your pixel integration with our testing guide
Complete API documentation for all event types
Learn how DAS Pixel data powers attribution
Related Topics
- Integration Overview - Choose your integration approach
- Session Management - Session tracking reference
- GDPR Compliance - Privacy and consent
- Troubleshooting - Common pixel issues
Updated about 2 months ago
