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

# Data Tags

> Learn how to organize and segment your data using tags in Oppla

# Data Tags

Learn how to use data tags to organize, segment, and analyze your tracking data in Oppla.

## What are Data Tags?

Data tags are labels you can add to your events and users to:

* Organize related data
* Create segments
* Filter analytics
* Group similar events

## Adding Tags to Events

### Using Data Attributes

Add tags to your events using data attributes:

```html theme={null}
<!-- Basic tagging -->
<button 
  id="signup-button" 
  data-oppla-event="Button Clicked"
  data-oppla-event-tags="conversion,signup,homepage">
  Sign up
</button>

<!-- Tag categories -->
<button 
  id="search-button" 
  data-oppla-event="Feature Used"
  data-oppla-event-feature="search"
  data-oppla-event-tags-category="core-feature"
  data-oppla-event-tags-priority="high"
  data-oppla-event-tags-stage="beta">
  Search
</button>
```

### Using JavaScript

Add tags programmatically:

```javascript theme={null}
// Browser implementation
window.oppla.track('Button Clicked', {
  buttonId: 'signup-button',
  tags: ['conversion', 'signup', 'homepage']
});

// With tag categories
window.oppla.track('Feature Used', {
  feature: 'search',
  tags: {
    category: 'core-feature',
    priority: 'high',
    stage: 'beta'
  }
});

// Node.js implementation
oppla.track('Button Clicked', {
  buttonId: 'signup-button',
  tags: ['conversion', 'signup', 'homepage']
});
```

## User Tags

### Adding User Tags

Tag users for segmentation:

```javascript theme={null}
// Browser implementation
window.oppla.identify({
  userId: 'user_123',
  traits: {
    name: 'John Doe',
    tags: ['premium', 'active', 'beta-tester']
  }
});

// Node.js implementation
oppla.identify({
  userId: 'user_123',
  traits: {
    name: 'John Doe',
    tags: ['premium', 'active', 'beta-tester']
  }
});
```

### Updating User Tags

Update user tags over time:

```javascript theme={null}
// Browser implementation
window.oppla.identify({
  userId: 'user_123',
  traits: {
    tags: {
      add: ['power-user'],
      remove: ['beta-tester']
    }
  }
});

// Node.js implementation
oppla.identify({
  userId: 'user_123',
  traits: {
    tags: {
      add: ['power-user'],
      remove: ['beta-tester']
    }
  }
});
```

## Tag Management

### Best Practices

1. **Be Consistent**: Use consistent tag names
2. **Be Specific**: Use descriptive tags
3. **Be Organized**: Group related tags
4. **Be Careful**: Don't use too many tags

### Common Tag Categories

* User type (e.g., 'free', 'premium')
* Feature usage (e.g., 'uses-search', 'uses-analytics')
* User stage (e.g., 'new', 'active', 'churned')
* Campaign (e.g., 'summer-sale', 'winter-promo')

## Using Tags in Analysis

### Filtering Data

Filter your analytics by tags:

```javascript theme={null}
// Browser implementation
window.oppla.analytics.getEvents({
  tags: ['conversion', 'signup']
});

window.oppla.analytics.getUsers({
  tags: ['premium', 'active']
});

// Node.js implementation
oppla.analytics.getEvents({
  tags: ['conversion', 'signup']
});
```

### Creating Segments

Create user segments based on tags:

```javascript theme={null}
// Browser implementation
window.oppla.analytics.createSegment({
  name: 'Power Users',
  tags: ['premium', 'active', 'power-user']
});

// Node.js implementation
oppla.analytics.createSegment({
  name: 'Power Users',
  tags: ['premium', 'active', 'power-user']
});
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Compare Metrics" icon="chart-line" href="/analytics/compare">
    Compare tagged data over time
  </Card>

  <Card title="Node Client" icon="server" href="/analytics/node-client">
    Server-side tag management
  </Card>
</CardGroup>
