# 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

```javascript
mtrix.init(config)
```

Initializes the Mtrix SDK with configuration options.

```javascript
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.&#x20;

{% hint style="info" %}
If you're using server-side initialization, audience details must be provided by you. For details visit here.
{% endhint %}

```javascript
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);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.mtrix.io/npm-package/markdown.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
