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

# Sales funnel

> Wire your upsell and downsell pages to the platform with one script tag and two data attributes.

After an approved purchase, the checkout sends the buyer to the funnel you configured for that offer. The upsell and downsell pages are yours, served from your own domain. The platform drives the flow from inside them with one script tag and two attributes on your buttons.

The whole integration is those two things. Everything else on this page is the detail that decides whether a click charges the card or throws the sale away.

## Build the funnel in the workspace

<Steps>
  <Step title="Create the funnel">
    Open **Sales Funnel** in the workspace and create a funnel. Every funnel created from now on opens in the V2 editor.
  </Step>

  <Step title="Add the steps">
    Each step is a node on the canvas: an upsell, a downsell, or a thank-you page. On the node you set the **page URL** on your domain and the **offer** that the buy button charges. Accepting a step follows the green path, declining follows the red one.
  </Step>

  <Step title="Split the traffic (optional)">
    A **Traffic Split** node sends buyers down up to **4 channels**, so you can compare two upsells against each other on the same funnel. Every channel carries a weight, and the weights have to add up to 100.
  </Step>

  <Step title="Publish">
    Saving keeps a **draft**, which changes nothing for buyers. **Publish** is what puts the funnel live.
  </Step>

  <Step title="Attach the funnel to the offer">
    In the offer, select the funnel. Publish the funnel before attaching it: a funnel that was never published has no entry step to run.
  </Step>
</Steps>

<Note>
  Funnels created before the V2 editor keep running and keep opening in the previous editor. There is no migration, and duplicating a V2 funnel is not available yet, so a funnel that needs Traffic Split has to be a new funnel.
</Note>

## 1. Add the script to every funnel page

Paste this as the last element before the closing `</body>` tag, on **every** page of the funnel:

```html theme={null}
<script src="https://scripts.pagamerican.net/s.js"></script>
```

Nothing works without it. The script reads the session the checkout handed over, charges the offer when the buyer accepts, and moves the buyer to the next step.

## 2. Mark the buttons

The script does not care what your buttons look like. It only looks for these attributes:

| Attribute | What it does |
| - | - |
| `data-pag-yes` | Marks the **buy** button. Only its presence counts, the value is ignored. |
| `data-pag-offer="CODE"` | Goes on the **same element** as `data-pag-yes`. It is the offer **code**, not the SKU. |
| `data-pag-no` | Marks the **decline** button, which leads to the downsell. Presence only, and it carries no offer code. |

Write the attributes bare: `data-pag-yes`, not `data-pag-yes="true"`. Each offer inside a node shows the snippet `data-pag-yes data-pag-offer="CODE"` with a **Copy** button next to it, with your offer code already filled in.

<Warning title="If you use <a>, leave it without href">
  What loses the sale is the `href`, not the tag. The script cancels the link navigation, but only after the page has **fully** loaded: every image, font and video. On a heavy VSL that takes seconds, and a buyer who clicks an `<a href>` in that window leaves the page. With no `href`, the same click simply does nothing and the buyer clicks again.

  Any tag works, as long as it carries no `href`: `<button>`, `<div>`, or `<a data-pag-yes data-pag-offer="CODE">`. The `href` is ignored either way, because the platform decides where the buyer goes next.
</Warning>

<Tip>
  The hand cursor is on you. A `<button>`, and an `<a>` without `href`, keep the arrow cursor and look unclickable. Add `style="cursor: pointer"` to the tag, or `cursor: pointer` in your CSS. That detail is exactly what tempts people into adding an `href`, which gets the hand cursor for free from the browser.
</Tip>

## The pair, ready to copy

```html theme={null}
<button type="button"
        data-pag-yes
        data-pag-offer="YOUR_OFFER_CODE"
        style="cursor: pointer">
  Yes, I want it
</button>

<button type="button"
        data-pag-no
        style="cursor: pointer">
  No, thanks
</button>
```

The same pair with anchors, for a page whose styling is built around links:

```html theme={null}
<a data-pag-yes data-pag-offer="YOUR_OFFER_CODE" style="cursor: pointer">Yes, I want it</a>

<a data-pag-no style="cursor: pointer">No, thanks</a>
```

Swap `YOUR_OFFER_CODE` for the code shown on your node.

## What the buyer sees on click

* **Accept**: a white overlay with a spinner covers the screen, the card on file is charged, and the page **redirects** to the next step. It is navigation, not a popup that closes.
* **Decline**: no overlay, straight to the next step.
* **Payment or tax error**: a red notice shows in the corner for 5 seconds and the page stays up, with the buttons enabled again.

## Test it end to end

Opening a funnel page directly in the browser shows a notice instead of your content, and that is expected. The page only runs when the buyer arrives from the checkout, because it needs the `pag_g` parameter the checkout puts on the URL. To test for real, make a test purchase and follow the flow.

## The domain has to match exactly

The page must be served from the same domain you registered on the node. `www.yourstore.com` and `yourstore.com` are different domains here, and a page whose domain does not match is refused.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.