Installation and Setup
To install and start using the Metrix WebSDK , follow the steps below:
To install using npm, run the following command in your project:
npm install @metrixorg/websdkAfter installation, initialize the Metrix WebSDK in your project using the following code:
import { init } from '@metrixorg/websdk';
init(APP_ID, API_KEY, config);Using the <script> tag:
If you cannot install via npm, you can include the script directly inside your project’s <head> tag:
<script src="https://cdn.metrix.ir/sdk/web/metrix.umd-2.4.0.js"></script>After adding the script, initialize the Metrix WebSDK using one of the methods below:
typescript:
declare let Metrix: any;
Metrix.init(APP_ID, API_KEY, config);javascript:
Metrix.init(APP_ID, API_KEY, config);The parameters that the init method receives are shown in the table below:
| Name | Type | Description | Required |
|---|---|---|---|
| APP_ID | string | The unique identifier for your application. You can find this in your Metrix dashboard under Workspace -> Settings -> App Info. | Yes |
| API_KEY | string | Obtain this key from Workspace -> Settings -> Api Key -> Generate Api Key in your Metrix dashboard, or create a new one. | Yes |