> ## Documentation Index
> Fetch the complete documentation index at: https://promptalpha.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Conversion Tracking

> Track conversions from AI search engine traffic

Conversion Tracking connects the dots between AI search engine traffic and business outcomes. By recording conversion events on your website, you can measure how many signups, purchases, and other key actions are driven by AI-referred visitors.

<Warning>
  Conversion Tracking requires the PromptAlpha tracking snippet to be installed on your site. If you have not set it up yet, follow the [Tracking Snippet](/docs/agent-analytics/tracking-snippet) guide first.
</Warning>

## Setting Up Conversion Tracking

Conversions are tracked by calling the `pa.track()` function from your website's JavaScript. The tracking snippet exposes a global `pa` object that you use to send conversion events to PromptAlpha.

### Basic Usage

```javascript theme={null}
pa.track('event_name');
```

### With Properties

```javascript theme={null}
pa.track('event_name', {
  email: 'user@example.com',
  value: 99.00,
  currency: 'USD'
});
```

The first argument is the event name (a string you define). The second argument is an optional object containing event properties.

## Code Examples

Here are common conversion events and how to implement them:

**Track a signup**

```javascript theme={null}
// Call this when a user completes your signup form
pa.track('signup', {
  email: 'user@example.com'
});
```

**Track a purchase**

```javascript theme={null}
// Call this on your order confirmation page
pa.track('purchase', {
  email: 'user@example.com',
  value: 99.00,
  currency: 'USD'
});
```

**Track a free trial start**

```javascript theme={null}
// Call this when a user starts a free trial
pa.track('trial_start', {
  email: 'user@example.com',
  plan: 'pro'
});
```

**Track a form submission**

```javascript theme={null}
// Call this when a user submits a contact or demo request form
pa.track('form_submit', {
  email: 'user@example.com',
  form: 'demo_request'
});
```

**Track a content download**

```javascript theme={null}
// Call this when a user downloads a resource
pa.track('download', {
  resource: 'pricing-guide.pdf'
});
```

<Info>
  Event names are case-sensitive. Use a consistent naming convention (e.g., `snake_case`) across all your conversion events to keep your data organized.
</Info>

## Event Properties Reference

The following properties are recognized by PromptAlpha for attribution and reporting:

| Property   | Type   | Description                                                                                 |
| ---------- | ------ | ------------------------------------------------------------------------------------------- |
| `email`    | string | The user's email address. Used to connect conversions to specific visitors across sessions. |
| `value`    | number | The monetary value of the conversion (e.g., purchase amount).                               |
| `currency` | string | The currency code for the value (e.g., `USD`, `EUR`, `GBP`). Defaults to `USD` if omitted.  |
| `plan`     | string | Optional label for subscription plan or tier.                                               |
| `form`     | string | Optional label identifying which form was submitted.                                        |
| `resource` | string | Optional label identifying which resource was downloaded.                                   |

You can also pass any custom properties as key-value pairs. Custom properties appear in your conversion reports and can be used for filtering.

<Note>
  The `email` property enables cross-session attribution. If a visitor arrives from ChatGPT on Monday and converts on Wednesday (returning via a direct visit), PromptAlpha can still attribute the conversion to ChatGPT if the same email is provided.
</Note>

## Full-Funnel Attribution

PromptAlpha tracks the complete journey from AI search discovery to conversion:

1. **AI search appearance** — your content is surfaced in an AI search engine
2. **Click-through** — the user clicks a link and arrives on your website
3. **Page visit** — PromptAlpha records the visit and identifies the AI source via the referrer
4. **Conversion** — the user completes a tracked action (signup, purchase, etc.)

This full-funnel view lets you see not just how many conversions come from AI traffic, but which AI platforms, landing pages, and content pieces drive the most valuable outcomes.

## Viewing Conversion Data in the Dashboard

Navigate to **Agent Analytics** > **Conversions** to see your conversion data. The dashboard includes:

* **Conversion summary** — total conversions, conversion rate, and total revenue from AI-referred traffic
* **By AI source** — conversions broken down by ChatGPT, Perplexity, Claude, Gemini, and other platforms
* **By event type** — conversions grouped by event name (e.g., `signup`, `purchase`, `trial_start`)
* **By landing page** — which entry pages lead to the most conversions
* **Conversion timeline** — a trend chart showing conversion volume over time

You can filter all views by date range, AI source, event name, and landing page.

<Tip>
  Use the **By AI Source** view to identify which AI platforms drive the highest-value conversions, not just the most traffic. A platform that sends fewer visitors but higher conversion rates may deserve more optimization attention.
</Tip>

## Revenue Attribution

When you include `value` and `currency` in your conversion events, PromptAlpha calculates revenue attribution metrics:

* **Total AI-attributed revenue** — the sum of all conversion values from AI-referred traffic
* **Revenue by AI source** — how much revenue each AI platform generates
* **Average order value** — the mean conversion value for AI-referred purchases
* **Revenue trend** — how AI-attributed revenue changes over time

Revenue data appears in the **Conversions** dashboard alongside your conversion counts.

```javascript theme={null}
// Example: tracking a purchase with revenue data
pa.track('purchase', {
  email: 'user@example.com',
  value: 149.00,
  currency: 'USD'
});
```

## Implementation Tips

<AccordionGroup>
  <Accordion title="Ensure pa.track() is called after the snippet loads">
    The `pa.track()` function is available after the tracking snippet finishes loading. Since the snippet uses the `defer` attribute, it loads after the HTML is parsed but before the `DOMContentLoaded` event. If you call `pa.track()` from an inline script in the `<head>`, it may not be available yet.

    **Recommended approach:** call `pa.track()` from event handlers (e.g., form submission handlers, button click handlers) or from scripts that run after `DOMContentLoaded`.

    ```javascript theme={null}
    document.addEventListener('DOMContentLoaded', function() {
      // Safe to use pa.track() here
      if (window.conversionCompleted) {
        pa.track('signup', { email: window.userEmail });
      }
    });
    ```
  </Accordion>

  <Accordion title="Avoid duplicate conversion events">
    Ensure `pa.track()` is called only once per conversion. Common causes of duplicates:

    * Calling `pa.track()` on a confirmation page that the user refreshes
    * Calling `pa.track()` inside a loop or repeated event handler

    Use a flag or server-side logic to prevent duplicate tracking:

    ```javascript theme={null}
    // Use sessionStorage to prevent duplicate tracking on page refresh
    if (!sessionStorage.getItem('purchase_tracked')) {
      pa.track('purchase', { email: 'user@example.com', value: 99.00, currency: 'USD' });
      sessionStorage.setItem('purchase_tracked', 'true');
    }
    ```
  </Accordion>

  <Accordion title="Test conversion events before going live">
    Use your browser's developer console to verify that `pa.track()` calls are executing without errors:

    1. Open your browser's developer tools (**F12** > **Console**).
    2. Trigger the conversion action on your site.
    3. Check the **Network** tab for outgoing requests to `app.promptalpha.ai`.
    4. Verify the request payload contains the correct event name and properties.

    Conversion events appear in the **Agent Analytics** > **Conversions** dashboard within a few minutes of being sent.
  </Accordion>
</AccordionGroup>
