Pixel Integration (v1)
Current Version - This is the latest version of the MDB pixel with improved reliability and performance. For the previous version, see Legacy Pixel.
Quick Start
Follow these three simple steps to start identifying your website visitors:Step 1: Login to MDB
- Go to mdb.tools/dash
- Login with your credentials
- Navigate to the dashboard
Step 2: Create a Webhook
Before setting up the pixel, you’ll need to configure where you want to receive visitor identification data:- Navigate to Webhooks in your MDB dashboard
- Create a new webhook endpoint URL
- Configure your webhook settings - See the Webhook Integration (v1) guide for details
- Save your webhook configuration
MDB uses Svix for reliable webhook delivery. You can view and manage your webhook event types at Svix Dashboard.
Step 3: Create and Deploy Your Pixel
- Create a new pixel in your MDB dashboard
- Copy your pixel ID - You’ll receive a guide after generation
- Add the pixel to your website using the script below:
PIXEL_ID with your actual pixel ID from the dashboard.
Implementation
Basic Implementation
With Custom Options
Parameters
PIXEL_ID- Your unique pixel ID from the MDB dashboardoptions- A stringified JavaScript object with custom configuration
Options Object
Theoptions parameter allows you to pass ANY custom data that will be included in your webhook responses. You have complete flexibility to structure your data however you need.
The only requirement: Your options object must be JSON stringified and URI encoded using encodeURIComponent(JSON.stringify(optionsObject)).
Common Use Cases
While you can include anything, common examples include:- Campaign tracking - Identify which campaigns are driving identified visitors
- Tenant/customer identification - Track which customer or client the visitor belongs to
- Page categorization - Segment data by page type or content category
- User segmentation - Track different user types or segments
- Product information - Include product IDs, categories, or pricing tiers
- Custom metadata - Any additional context your application needs
Example with Proper Encoding
Multi-Tenancy Support
The MDB pixel has built-in support for multi-tenant applications. Any custom options you pass during pixel initialization will be echoed back to you in every webhook associated with that visitor session. This makes it easy to route and process webhook data for multiple customers or tenants.How It Works
- At pixel init - Include tenant-specific data in your options object
- MDB processes the visitor - The options are stored with the session
- Webhook delivery - Your options are included in the webhook payload, allowing you to identify which tenant the data belongs to
Multi-Tenant Example
Webhook Response
When MDB identifies a visitor, your webhook will include the options you provided:The
options object in the webhook payload is an exact echo of what you passed during pixel initialization. Use this to route data to the correct tenant, apply tenant-specific logic, or enrich your CRM with customer context.Use Cases
- White-label solutions - Maintain separate data streams per customer
- Resellers - Route leads to the appropriate partner
Debug Mode
For troubleshooting pixel integration issues, you can enable debug mode by addingmdb_pixel_debug=true to your page URL:
- “mdb pixel loaded” - Pixel successfully initialized and loaded
- “mdb pixel error” - Pixel failed to load or initialize
Debug mode only affects console logging and doesn’t change pixel functionality. Remove the debug parameter for production use.
Best Practices
- Test thoroughly - Always test your pixel implementation in a development environment first
- Validate options - Ensure your options object is valid JSON before deployment
- Monitor performance - The pixel is designed to be lightweight, but monitor your site’s performance
- Use meaningful options - Include options that will be useful in your webhook processing
- Use debug mode - Enable debug mode during development to troubleshoot integration issues
What’s New in v1?
The v1 pixel includes several improvements over the legacy version:- Improved reliability - Enhanced error handling and retry logic
- Better performance - Optimized loading and execution
- Enhanced tracking - More accurate session management
- Clearer versioning - Explicit version in the URL path
Migration from Legacy
If you’re using the legacy pixel (https://p.mdb.tools/TRACKING_ID), see the Legacy Pixel documentation for migration guidance.
Next Steps
Once you have the pixel implemented:- Set up webhook handling - Configure your server to receive and process webhooks
- Access webhook portal - Visit mdb.tools/dash/pixel-wrap/webhook-portal to manage webhooks
- Review event types - Check available webhook events and their payloads
- Understand billing - Learn how MDB’s credit system works
- Test identification - Verify that visitor identification is working correctly