> For the complete documentation index, see [llms.txt](https://alhena.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alhena.gitbook.io/docs/developer-reference/website-sdk/cart-checkout-events/revenue-attribution.md).

# Revenue Attribution

Understand how Alhena AI measures the revenue impact of your AI assistant by tracking conversions from chat interactions, FAQ engagement, and proactive nudges.

## What is Revenue Attribution?

Alhena AI automatically tracks when your AI assistant influences a purchase, so you can see the **direct revenue impact** of your AI investment. This data helps you understand ROI and optimize your AI's effectiveness.

## How It Works

### Step 1: Track User Sessions

When a customer interacts with your Alhena AI (via **chat widget**, **FAQ**, or **nudges**), we capture a **unique session identifier**. This links their conversation to their shopping activity.

### Step 2: Connect Purchases to Conversations

When a customer completes a purchase, we match their checkout to any AI conversations they had. This tells us **which sales were influenced** by your AI assistant.

### Step 3: Attribute Revenue

We credit revenue to the AI interaction that most likely influenced the purchase:

| Channel            | Description                               |
| ------------------ | ----------------------------------------- |
| Chat conversations | Customer asked questions via chat widget  |
| FAQ interactions   | Customer clicked on a product FAQ         |
| Nudge clicks       | Customer engaged with a proactive message |

***

## Attribution Rules

| Rule                     | Description                                                                     |
| ------------------------ | ------------------------------------------------------------------------------- |
| **7-day window**         | We only attribute purchases made within 7 days of an AI interaction             |
| **First touch priority** | If a customer used both chat and FAQ, we attribute to whichever they used first |
| **Answer quality**       | We only count interactions where the AI provided helpful answers                |

### How "Helpful" is Defined

An answer is considered "helpful" when Alhena AI successfully finds a relevant answer from your knowledge base (not when it says "I don't know" or escalates to a human).

***

## Platform Setup

### Shopify Integration

If you use **Shopify**, revenue tracking is **fully automatic**. We capture purchase data via webhooks—**no code changes needed**.

### Non-Shopify Platforms

For WooCommerce, custom e-commerce platforms, or other systems, you need to implement cart and checkout event tracking:

* **JavaScript API (Client-Side):** See [Cart & Checkout Event API](/docs/developer-reference/website-sdk/cart-checkout-events.md) for the `trackAlhenaEvent` function
* **HTTP API (Server-Side):** See [HTTP APIs](/docs/developer-reference/website-sdk/cart-checkout-events/http-apis.md) for backend integration
* **WooCommerce:** See [WooCommerce Revenue Tracking](/docs/developer-reference/website-sdk/examples/woocommerce-revenue-tracking.md) for a complete example

***

## What You'll See in Your Dashboard

Navigate to **Analytics > Revenue Impact** in the Alhena dashboard to view:

| Metric                       | Description                          |
| ---------------------------- | ------------------------------------ |
| **Total attributed revenue** | Sales influenced by AI conversations |
| **Revenue by channel**       | Breakdown by chat, FAQ, and nudges   |
| **Trend comparisons**        | How revenue impact changes over time |

***

## Why This Matters

Instead of guessing whether your AI is helping sales, you get **concrete data**:

> "Customers who chatted with Alhena AI had **$X in attributed revenue** this month."

This helps you:

* Prove ROI on your AI investment
* Identify which AI features drive the most revenue
* Optimize your AI responses for better conversions
* Make data-driven decisions about AI configuration

***

## Related Resources

* [Cart & Checkout Event API](/docs/developer-reference/website-sdk/cart-checkout-events.md) - JavaScript tracking API
* [HTTP APIs](/docs/developer-reference/website-sdk/cart-checkout-events/http-apis.md) - Server-side tracking endpoints
* [A/B Testing](/docs/developer-reference/website-sdk/ab-testing.md) - Measure AI impact with experiments
