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. Getting Started

Quick Start Guide

After the installation of the package, follow these steps to get Mtrix up and running in your application:

1. Create an Account

Get your up organization ID and project ID at app.mtrix.io.

2. Initialize Mtrix

Add the following code to the entry point of your application:

import mtrix from 'mtrix';

mtrix.init({
  organizationId: 'your-organization-id',
  projectId: 'your-project-id',
  environment: 'production',
  options: {
    // additional optimization
  }
});

mtrix.onReady().then(() => {
  console.log(mtrix)
  // get experiment details
});
import React from 'react';
import ReactDOM from 'react-dom';
import mtrix from 'mtrix';
import App from './App';

// Initialize Mtrix
mtrix.init({
  organizationId: 'your-organization-id',
  projectId: 'your-project-id',
  environment: 'production'
});

ReactDOM.render(<App />, document.getElementById('root'));
// pages/_app.js
import { useEffect } from 'react';
import mtrix from 'mtrix';

function MyApp({ Component, pageProps }) {
  useEffect(() => {
    // Initialize Mtrix
    mtrix.init({
      organizationId: 'your-organization-id',
      projectId: 'your-project-id',
      environment: process.env.NODE_ENV
    });
  }, []);

  return <Component {...pageProps} />;
}

export default MyApp;

3. Track Your First Event

After initialization, you can start tracking events:

// Track a button click
document.getElementById('signup-button').addEventListener('click', () => {
    mtrix.trackEvent('SignupButtonClicked', {
        location: 'hero-section',
        referrer: document.referrer 
    });
});

4. Implement A/B Testing

Fetch and apply experiment configurations:

// Get experiment details for the current page
async function loadExperiments() {
    const userId = getUserId(); // Your function to get user ID
    const pageLocation = window.location.pathname;
    const experiments = await mtrix.getPageDetails({
        location: pageLocation, // pageLocation must met the value on the Mtrix dashboard
        userId: userId
    });
}
PreviousInstallationNextConfiguration Options

Last updated 1 month ago