Martech Integration
This cookbook shows how a martech company can integrate MDB into their existing pixel infrastructure with multi-tenancy support and scalable, production-ready serverless architecture.This guide shows examples using both the legacy pixel format and the new v1 pixel format. For new integrations, use the v1 Pixel format:
https://p.mdb.tools/v1/PIXEL_IDMartech Multi-Tenant Integration
This example shows how a martech company can integrate MDB into their existing pixel infrastructure with multi-tenancy support and scalable serverless processing.Scenario
You’re a martech product with:- Existing pixels deployed on multiple customer sites
- Multi-tenant architecture with multiple clients
- Need to attribute website visitors to your own system
- Requirement for scalable, serverless processing
Architecture Overview
Step 1: Modify Your Existing Pixel
Update your existing pixel to load the MDB pixel with tenant identification:Self-Executing Function Example
Multi-Tenant Configuration
Step 2: Scalable Serverless Webhook Handler
Create a serverless function that can handle high-volume webhook traffic:AWS Lambda Example
Firebase Functions Example
Step 3: Queue-Based Event Processing
Process events from your queue system for scalability:AWS SQS + Lambda Processor
Pub/Sub Processing Example
Step 4: Database Schema for Multi-Tenancy
Design your database schema to handle multi-tenant visitor data:PostgreSQL Schema Example
Step 5: Monitoring and Observability
Implement comprehensive monitoring for your integration:CloudWatch/Application Insights Metrics
Best Practices Summary
Scalability
Scalability
- Use serverless functions for webhook handling
- Implement queue-based processing for high volume
- Design for horizontal scaling with proper partitioning
- Use appropriate database indexes for query performance
Multi-Tenancy
Multi-Tenancy
- Include tenant_id in all pixel options
- Isolate tenant data at the database level
- Implement tenant-specific configuration
- Monitor per-tenant usage and performance
Reliability
Reliability
- Implement proper error handling and retries
- Use dead letter queues for failed processing
- Design idempotent processing logic
- Monitor webhook delivery success rates
Security
Security
- Validate all webhook payloads
- Use HTTPS for all endpoints
- Implement proper authentication
- Sanitize and validate tenant data
Next Steps
- Start with a single tenant - Implement and test with one client first
- Monitor performance - Track latency, throughput, and error rates
- Scale gradually - Add tenants and monitor system performance
- Optimize based on usage - Adjust queue sizes, function timeouts, and database queries based on real usage patterns