Core API Reference
The Mtrix package provides a simple yet powerful API for integrating analytics and experimentation into your website.
Upon successful initialization, Mtrix will:
Verify your organization and project IDs
Set up enabled features based on configuration
Begin collecting basic page data
Record an initialization event
If your debug key set to true, you can check the initialization status in your browser console, where you should see:
Mtrix initialized: v1.1.0
Core Methods
mtrix.init(config)
Initializes the Mtrix SDK with configuration options.
mtrix.init({
organizationId: 'org-123',
projectId: 'proj-456',
environment: 'production'
});
mtrix.trackEvent(eventName, properties)
Records a custom event with optional properties.
mtrix.trackEvent('ButtonClicked', {
buttonId: 'signup-button',
location: 'hero-section'
});
mtrix.getPageDetails(params)
Retrieves experiment configurations for a specific page and user.
const experiments = await mtrix.getPageDetails({
location: '/checkout',
userId: 'user-123',
audience: [
{
audienceKey: 'country',
value: 'CA'
}
]
});
console.log(experiments);
{
}
mtrix.getPerformance()
Retrieves the current performance metrics collected.
const metrics = mtrix.getPerformance();
console.log('LCP:', metrics.LCP, 'CLS:', metrics.CLS);
Last updated