49 lines
1.1 KiB
Plaintext
49 lines
1.1 KiB
Plaintext
---
|
|
title: Javascript (Web)
|
|
description: The OpenPanel Web SDK allows you to track user behavior on your website using a simple script tag. This guide provides instructions for installing and using the Web SDK in your project.
|
|
---
|
|
|
|
import { Step, Steps } from 'fumadocs-ui/components/steps';
|
|
import { PersonalDataWarning } from '@/components/personal-data-warning';
|
|
import CommonSdkConfig from '@/components/common-sdk-config.mdx';
|
|
import WebSdkConfig from '@/components/web-sdk-config.mdx';
|
|
|
|
## Installation
|
|
|
|
<Steps>
|
|
### Step 1: Install
|
|
|
|
```bash
|
|
npm install @openpanel/web
|
|
```
|
|
|
|
### Step 2: Initialize
|
|
|
|
```js title="op.ts"
|
|
import { OpenPanel } from '@openpanel/web';
|
|
|
|
const op = new OpenPanel({
|
|
clientId: 'YOUR_CLIENT_ID',
|
|
trackScreenViews: true,
|
|
trackOutgoingLinks: true,
|
|
trackAttributes: true,
|
|
});
|
|
```
|
|
|
|
#### Options
|
|
|
|
<CommonSdkConfig />
|
|
<WebSdkConfig />
|
|
|
|
### Step 3: Usage
|
|
|
|
```js title="main.ts"
|
|
import { op } from './op.js';
|
|
|
|
op.track('my_event', { foo: 'bar' });
|
|
```
|
|
</Steps>
|
|
|
|
## Usage
|
|
|
|
Refer to the [Javascript SDK](/docs/sdks/javascript#usage) for usage instructions. |