LogoLogo
  • Overview
  • Key Features
  • Getting Started
    • Installation
    • Quick Start Guide
    • Configuration Options
    • Authentication
  • NPM Package
    • Installation
    • Core API Reference
    • Event Tracking
    • Experimentation
    • Performance Monitoring
    • Session Recording
    • Error Tracking
    • Advanced Configuration
  • A/B Testing & Experimentation
    • Creating Experiments
    • Targeting Users
    • Measuring Results
    • Statistics & Significance
    • Best Practices
  • Analytics Dashboard
    • Overview
    • User Journey Analysis
    • Conversion Funnels
    • Custom Reports
  • Session Recording
    • Privacy Considerations
    • Viewing Recordings
    • Filtering & Searching
    • Heatmaps
  • Performance Monitoring
    • Core Web Vitals
  • User Management
    • Roles & Permissions
    • Team Collaboration
    • Access Controls
    • Audit Logs
  • Troubleshooting
    • Common Issues
    • Debugging Tools
    • Error Reference
  • Appendix
    • Glossary
    • API Status Codes
    • Migration Guides
    • Release Notes
    • Roadmap
Powered by GitBook
On this page
  1. NPM Package

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:

  1. Verify your organization and project IDs

  2. Set up enabled features based on configuration

  3. Begin collecting basic page data

  4. 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.

If you're using server-side initialization, audience details must be provided by you. For details visit here.

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);
PreviousInstallationNextEvent Tracking

Last updated 1 month ago