# Analytics

The Analytics API enables you to collect analytics data for your app.

## Track Events

To record an event use the `track` method of BlueBase's Analytics API.

```typescript
BB.Analytics.track({ name: 'albumVisit' });
```

## **Record a Custom Event with Attributes**

The `track` method lets you add additional attributes to an event. For example, to record *artist* information with an *albumVisit* event:

```typescript
BB.Analytics.track({
    name: 'albumVisit', 
    // Attribute values must be strings
    attributes: { genre: '', artist: '' }
});
```

## **Record Engagement Metrics**

Data can also be added to an event:

```typescript
BB.Analytics.track({
    name: 'albumVisit', 
    attributes: {}, 
    metrics: { minutesListened: 30 }
});
```

## Integrations

To add support for an Analytics Provider see this [guide](/bluerain/key-concepts/plugins/developing-an-analytics-plugin.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blueeast.gitbook.io/bluerain/key-concepts/analytics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
