Files
stats/apps/docs/src/pages/docs/sdks/web.mdx
Carl-Gerhard Lindesvärd df05e2dab3 Self-hosting! (#49)
* added self-hosting
2024-08-28 09:28:44 +02:00

48 lines
1.0 KiB
Plaintext

import { Callout, Tabs, Steps } from 'nextra/components';
import { PersonalDataWarning } from 'src/components/personal-data-warning';
import CommonSdkConfig from 'src/components/common-sdk-config.mdx';
import WebSdkConfig from 'src/components/web-sdk-config.mdx';
# Web SDK
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.
## Installation
<Steps>
### Step 1: Install
```bash
npm install @openpanel/web
```
### Step 2: Initialize
```js filename="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 filename="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.