# 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                                                                     |
| ------------------------ | ------------------------------------------------------------------------------- |
| **24-hour window**       | We only attribute purchases made within 24 hours 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](https://alhena.gitbook.io/docs/developer-reference/website-sdk/cart-checkout-events) for the `trackAlhenaEvent` function
* **HTTP API (Server-Side):** See [HTTP APIs](https://alhena.gitbook.io/docs/developer-reference/website-sdk/cart-checkout-events/http-apis) for backend integration
* **WooCommerce:** See [WooCommerce Revenue Tracking](https://alhena.gitbook.io/docs/developer-reference/website-sdk/examples/woocommerce-revenue-tracking) 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](https://alhena.gitbook.io/docs/developer-reference/website-sdk/cart-checkout-events) - JavaScript tracking API
* [HTTP APIs](https://alhena.gitbook.io/docs/developer-reference/website-sdk/cart-checkout-events/http-apis) - Server-side tracking endpoints
* [A/B Testing](https://alhena.gitbook.io/docs/developer-reference/website-sdk/ab-testing) - Measure AI impact with experiments


---

# 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://alhena.gitbook.io/docs/developer-reference/website-sdk/cart-checkout-events/revenue-attribution.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.
