# Analytics (Mixpanel)

## Mixpanel Event Tracking Documentation

This file contains functions to track various events using Mixpanel.

### Initialization

Mixpanel must be initialized with your project token before using the tracking functions.

### Functions

#### `trackEvent(eventName: string, userId: string, properties?: Record<string, any>): void`

This function tracks a custom event with Mixpanel. It requires the event name, user ID, and optionally additional properties.

#### `trackSignedUp(userId: string, signupType: string, plan: string): void`

Tracks the event when a user signs up for the application. Requires the user ID, signup type, and plan chosen by the user.

#### `trackLoggedIn(userId: string, loginMethod: string): void`

Tracks the event when a user logs in to the application. Requires the user ID and the method used for login.

#### `trackProductViewed(userId: string, productId: string, category: string): void`

Tracks the event when a user views a product. Requires the user ID, product ID, and category of the product.

#### `trackItemAddedToCart(userId: string, productId: string, quantity: number): void`

Tracks the event when a user adds an item to their shopping cart. Requires the user ID, product ID, and quantity added.

#### `trackOrderCompleted(userId: string, orderId: string, totalAmount: number, paymentMethod: string): void`

Tracks the event when a user completes an order. Requires the user ID, order ID, total amount of the order, and payment method.

#### `trackPageViewed(userId: string, pageUrl: string, pageTitle: string): void`

Tracks the event when a user views a specific page. Requires the user ID, URL, and title of the page.

These functions can be used to track user interactions and behaviors within your application using Mixpanel.


---

# 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.flutfast.com/analytics-mixpanel.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.
