> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oppla.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Add a Product

> Learn how to add Oppla analytics to your product in minutes

# Add a Product

Get started with Oppla analytics in just a few simple steps. Track user behavior, feature usage, and experiments with a single lightweight script.

## Quick Start

### Step 1: Get Your Product Credentials

1. Log into your [Oppla Dashboard](https://app.oppla.ai)
2. Navigate to **My Products** → **Add Product**
3. Click **Add Product**
4. Copy your `Product ID` and `Account ID`

### Step 2: Add the Tracking Script

Add this script to your product's `<head>` section:

```html theme={null}
<script async defer
  src="https://tracker.oppla.ai/script.js"
  data-website-id="YOUR_PRODUCT_ID"
  data-account-id="YOUR_ACCOUNT_ID">
</script>
```

**That's it!** Oppla will automatically start tracking:

* Page views
* User sessions
* Click events (with `data-oppla-event` attributes)
* Feature flag usage
* Experiment participation

## Advanced Features

### Track Custom Events

Track button clicks, form submissions, or any custom event:

```html expandable theme={null}
<!-- Track button clicks -->
<button data-oppla-event="signup-clicked"
        data-oppla-event-plan="pro">
  Sign Up for Pro
</button>

<!-- Track form submissions -->
<form data-oppla-event="contact-form-submitted">
  <!-- your form fields -->
</form>
```

### Identify Users

Track logged-in users across sessions:

```javascript expandable theme={null}
// When user logs in
window.oppla.identify('user-123', {
  email: 'user@example.com',
  plan: 'premium',
  company: 'Oppla AI'
});
```

### Feature Flags

Control feature visibility based on user segments:

```javascript expandable theme={null}
// Check if a feature is enabled
if (window.oppla.getFeatureFlagStatus('new-dashboard')) {
  // Show new dashboard
}
```

### A/B Testing

Run experiments to optimize your user experience:

```javascript expandable theme={null}
// Get experiment variant
const variant = window.oppla.getExperimentStatus('homepage-cta');

if (variant === 'variant-a') {
  // Show variant A
} else if (variant === 'variant-b') {
  // Show variant B
}
```

## Configuration

### Configuration Options

Customize tracking behavior with optional attributes:

```javascript expandable theme={null}
<script async defer
  src="https://tracker.oppla.ai/script.js"
  data-website-id="YOUR_PRODUCT_ID"
  data-account-id="YOUR_ACCOUNT_ID"
  data-auto-track="true"              <!-- Enable automatic tracking (default: true) -->
  data-exclude-search="true"          <!-- Exclude URL parameters (default: false) -->
  data-exclude-hash="true"            <!-- Exclude URL hash (default: false) -->
  data-do-not-track="true"            <!-- Respect browser DNT (default: false) -->
  data-domains="app.example.com,example.com">  <!-- Track specific domains -->
</script>
```

### JavaScript API

Once installed, these methods are available globally:

```javascript expandable theme={null}
// Track custom events
window.oppla.track('event-name', {
  property1: 'value1',
  property2: 'value2'
});

// Identify users
window.oppla.identify('user-id', {
  email: 'user@example.com',
  customProperty: 'value'
});

// Feature flags
const isEnabled = window.oppla.getFeatureFlagStatus('feature-id');

// Experiments
const variant = window.oppla.getExperimentStatus('experiment-id');

// Automation triggers
window.oppla.trigger('trigger-name', 'automation-id', {
  customData: 'value'
});
```

## Verification

### Testing the Installation

1. **Check the Console**
   * Open browser Developer Tools (F12)
   * Type `window.oppla` in the Console
   * You should see the Oppla object with available methods

2. **Check Network Activity**
   * Go to Network tab in Developer Tools
   * Look for requests to `tracker.oppla.ai`
   * Verify requests to `/api/send` are successful (200 status)

3. **Check Your Dashboard**
   * Visit your [Oppla Dashboard](https://app.oppla.ai)
   * Navigate to **Analytics** → **Real-time**
   * You should see your current session

### Common Issues

* **`window.oppla is undefined`**: Ensure the script is in the `<head>` section and has loaded
* **No data in dashboard**: Verify your Product ID and Account ID are correct
* **Blocked by ad blocker**: Ask users to whitelist `tracker.oppla.ai`
* **Not tracking localhost**: Localhost tracking is disabled by default for development

## Next Steps

<CardGroup cols={2}>
  <Card title="Track Events" icon="chart-line" href="/analytics/track-events">
    Learn how to track custom events
  </Card>

  <Card title="Feature Flags" icon="toggle-on" href="/features/feature-flags">
    Control feature rollouts and A/B tests
  </Card>

  <Card title="User Segments" icon="users" href="/analytics/segments">
    Create user segments for targeted features
  </Card>

  <Card title="API Reference" icon="code" href="/api/javascript-sdk">
    Complete JavaScript SDK documentation
  </Card>
</CardGroup>
