# Tracking Analytics

## Track

Once you're set up, tracking events is easy as 🥧:

```javascript
Plaudy.track("purchase", {
    "amount": 413.25,
    "upsell": 63.25,
    "referrer": "landing page",
    "items": [
        "dehydrated h20",
        "non-gmo water",
        "filtered dirt"
    ],
    "user_id": `USER_ID` // if you didn't pass this in when using .identify()
    "object_id": `OBJECT_ID` // if you didn't pass this in when using .identify()
    // anything else
});
```

The first argument is the `event_type`, which you can call whatever you'd like. The second argument is any data you want to pass in (up to 1,000 key-value pairs).

{% hint style="info" %}
`count` is a preserved keyword and will determine how much the counter for this event type and user increments because of this event. In most cases, you will not need to pass this in.
{% endhint %}

## Examples

### 1. Tracking A Page View

Here's a simple example of everything together in a file we'll call `index.js`. We'll be tracking a single page view:

{% code title="index.js" %}

```javascript
import Plaudy from 'plaudy';

Plaudy.init(`YOUR_API_KEY`);
Plaudy.identify(`USER_ID`, `OBJECT_ID`);

Plaudy.track("page view", {
    "title": window.location.hostname,
    "url": "https://docs.plaudy.com"
});
```

{% endcode %}

That's it! You successfully tracked your first page view for this user! But there's so much more you can do! [Keep it going](/displaying-analytics.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://docs.plaudy.com/tracking-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.
