> ## 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.

# Tour Analytics

> Learn how to track and analyze tour performance in Oppla

# Tour Analytics

Learn how to track and analyze tour performance using Oppla's analytics features.

## Basic Usage

### Track Tour Events

```javascript theme={null}
import { createTour } from '@oppla-ai/tours';

const tour = createTour({
  id: 'feature-tour',
  steps: [
    {
      type: 'tooltip',
      target: '#feature-button',
      content: 'Try our new feature!'
    }
  ],
  analytics: {
    trackViews: true,
    trackInteractions: true
  }
});

tour.start();
```

### Track Custom Events

```javascript theme={null}
{
  type: 'tooltip',
  target: '#feature-button',
  content: 'Try our new feature!',
  analytics: {
    trackEvent: 'feature_tooltip_shown',
    properties: {
      feature_name: 'new-feature',
      step_index: 0
    }
  }
}
```

## Advanced Features

### Track User Interactions

```javascript theme={null}
{
  type: 'tooltip',
  target: '#feature-button',
  content: 'Try our new feature!',
  onShow: () => {
    window.oppla.track('tooltip_shown', {
      tour_id: 'feature-tour',
      step_index: 0
    });
  },
  onClick: () => {
    window.oppla.track('tooltip_clicked', {
      tour_id: 'feature-tour',
      step_index: 0
    });
  }
}
```

### Track Tour Progress

```javascript theme={null}
{
  type: 'tooltip',
  target: '#feature-button',
  content: 'Try our new feature!',
  onComplete: () => {
    window.oppla.track('tour_step_completed', {
      tour_id: 'feature-tour',
      step_index: 0,
      time_spent: 5000 // milliseconds
    });
  }
}
```

## Best Practices

1. **Be Consistent**: Use consistent event names and properties
2. **Be Specific**: Track meaningful user interactions
3. **Be Organized**: Group related events logically
4. **Be Clean**: Remove unused tracking code

## Common Issues

### Events Not Tracking

* Check event names
* Verify properties
* Check initialization
* Ensure proper timing

### Data Quality

* Validate event data
* Check for duplicates
* Monitor event volume
* Review property values

## Next Steps

<CardGroup cols={2}>
  <Card title="Tooltips" icon="comment" href="/tours/tooltip">
    Learn about tooltip steps
  </Card>

  <Card title="Modals" icon="window-maximize" href="/tours/modal">
    Learn about modal steps
  </Card>
</CardGroup>
