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
});
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
});
}
Last updated