# Track Conversions with Poltio SDK

Source: https://platform.poltio.com/docs/conversion/

Learn how to track conversions effectively using the Poltio SDK.

# Track Conversions with Poltio SDK

---

## Step 1: Basic Setup {{ tag: 'Required' }}

To start tracking conversions, Poltio Tag needs to be on all your **product detail pages** and **checkout success pages**.

Your tag is unique to your account, so you get it ready to use from [Poltio Panel](https://poltio.app) rather than copying it from this page. Open the sidebar and click **Poltio Tag** under **Resources**.

A dialog opens with the tag already filled in with your Account ID. Copy it with the button in the top right corner of the code box.

> **Note:** **Important:** Ensure the script is included in the `<head>` section of your page

To confirm the tag is live, enter one of your page URLs at the bottom of the same dialog and click **Check Poltio Tag**. Allow 5-10 minutes after deploying before you check.

> **Note:** In [no-cookie mode](/docs/cookies/#no-cookie-mode), a purchase is attributed only if it happens in the same browser tab as the widget visit.

Once you've added this code, configure your **checkout success URL** in the [Poltio Platform](https://poltio.app).

---

## Step 2: Measuring Cart Totals {{ tag: 'Optional & Recommended', label: 'Track not only quantities but also values'}}

To track the cart value, add the following snippet to your **checkout page** using Google Tag Manager or directly in your code.

> **Note:** If you're already using the Meta/Facebook Conversion Pixel, you can reuse your existing code by replacing `fbq` with `window.poltio.push`.

Example code for tracking cart totals:

````html
<script>
  window.poltio.push('track', 'Purchase', {currency: "USD", value: 30.00});
</script>
````

> **Note:** **Important:** This snippet only works if Poltio Tag is already in the `<head>` section of the same page. If you have not installed it yet, copy it from **Poltio Tag** under **Resources** in [Poltio Panel](https://poltio.app) as described in Step 1.

---

## Step 2a:  Detailed Tracking with Items {{ tag: 'Optional', label: 'Track detailed product information'}}

For more detailed tracking, you can send product details (SKUs) using the `window.poltio.push('track')` function. Here's an example:

````html
<script>
  window.poltio.push('track', 'Purchase', {
    value: 4.99,
    poltio_account_id: PoltioID,
    contents: [
      { id: 'testProduct1', quantity: 1, value: 2.99 },
      { id: 'testProduct2', quantity: 2, value: 1.0 },
    ],
    currency: 'USD',
    order_id: 'testOrder1',
  });
</script>
````

> **Note:** If you are using Google Tag Manager to include Poltio Tag and Poltio Conversion Tracking code, make sure Poltio Tag trigger has higher priority in order to make sure it loads before Conversion Tracking code to prevent race conditions.

### Parameters:
- **`value`**: (Required) The total monetary value of the purchase.
- **`poltio_account_id`**: (Required) A unique identifier of your Poltio account.
- **`contents`**: (Optional) An array of objects containing product details:
  - **`id`**: Product identifier.
  - **`quantity`**: Quantity of the product.
  - **`value`**: Monetary value of the product.
- **`currency`**: (Optional) The currency of the transaction.
- **`order_id`**: (Optional) A unique identifier for the order.

> **Note:** Your Poltio account's unique identifier is the Account ID in the menu at [Poltio Platform](https://poltio.app).

---

## Custom Domain {{ tag: 'Optional & Recommended', label: 'Enhance tracking efficiency across all platforms' }}

For comprehensive tracking across all platforms, including mobile and environments with stricter privacy settings, configure a custom domain. This allows you to use first-party cookies by setting up a subdomain of your primary site.

Visit the [Custom Domain Documentation](/docs/customdomain/) to learn how to set up a custom domain.

After setting up a custom domain, take the tag you copied from [Poltio Panel](https://poltio.app) and replace the `https://sdk.poltio.com` value with your subdomain address:

```js
// without PUID and Custom ID
"https://sdk.poltio.com","poltio.js","1234"
"https://poltio.yourdomain.com","poltio.js","1234"

// with PUID
"https://sdk.poltio.com","poltio.js","1234","your-user-id"
"https://poltio.yourdomain.com","poltio.js","1234","your-user-id"

// with PUID and Custom ID
"https://sdk.poltio.com","poltio.js","1234","your-user-id","your-custom-id"
"https://poltio.yourdomain.com","poltio.js","1234","your-user-id","your-custom-id"
````

> **Note:** Leave the rest of the tag untouched, including your Account ID. Only the address changes.

---

By following these steps, you can easily track user interactions and conversions on your website using the Poltio SDK.
