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

# Conversions the page can fire (public)

> Anonymous and read-only: what the site’s own pages load to fire conversions in the browser.

```php Laravel wrap theme={"dark"}
use Fetchski\AttractCmsLaravel\Facades\Attract;

$listActiveConversions = Attract::conversions()->listActiveConversions();
```

```json 200 wrap theme={"dark"}
{
  "conversions": [
    {
      "id": "ckq1w2e3r4t5y6u7i8o9p0",
      "key": "phone-call",
      "counting": "once",
      "value": null,
      "currency": "USD",
      "sendUserData": true,
      "destinations": [
        "google-ads",
        "ga4"
      ],
      "platforms": {
        "google-ads": {
          "sendTo": "AW-123456789/AbC-D_efG"
        },
        "ga4": {
          "event": "contact"
        }
      },
      "triggers": {
        "forms": [],
        "links": [
          "tel:*"
        ],
        "outbound": false,
        "downloads": [],
        "chat": [],
        "pageView": false
      }
    }
  ]
}
```

## In your app

A controller answers a route on your app: it calls `listActiveConversions()` and returns the answer.

**1. Add the controller**

```php app/Http/Controllers/ListActiveConversionsController.php theme={"dark"}
<?php

declare(strict_types=1);

namespace App\Http\Controllers;

use Fetchski\AttractCmsLaravel\Data\ListActiveConversionsResponse;
use Fetchski\AttractCmsLaravel\Facades\Attract;

final class ListActiveConversionsController
{
    public function __invoke(): ListActiveConversionsResponse
    {
        return Attract::conversions()->listActiveConversions();
    }
}
```

**2. Add the route**

```php routes/web.php theme={"dark"}
use App\Http\Controllers\ListActiveConversionsController;
use Illuminate\Support\Facades\Route;

Route::get('/conversion/active', ListActiveConversionsController::class);
```

**3. Call it**

```bash Terminal theme={"dark"}
curl http://localhost:8000/conversion/active
```

With `php artisan serve` running, it prints its answer as JSON.

> [!TIP]
>
> To keep the call in an Action instead, this writes `app/Actions/Attract/ListActiveConversions.php` (an invokable Action that calls `listActiveConversions()`) and its test under `tests/Feature/Actions/Attract/` (Pest when your app has it):
>
> ```bash Terminal theme={"dark"}
> php artisan make:attract-action conversions.listActiveConversions
> ```

## Call it from the terminal

```bash Terminal theme={"dark"}
php artisan attract:call conversions.listActiveConversions
```

It calls `listActiveConversions()` on your default site and prints its answer as JSON. See [Call any method from the terminal](https://docs.fetchski-attract.com/call-command.md) for every argument type.

Each enabled Conversion with a browser trigger, compiled, with only its rows sent from the page and its page-view triggers resolved against `path` to a yes/no. No names, no server-only IDs, and never the site’s page list. Integrations should use `GET /conversion/definitions` instead.

> [accordion] Optional parameters
>
> Named arguments, e.g. `listActiveConversions(path: …)`; leave out the optional ones.
>
> **path** `?string`
>
> **Optional.** Leave it out and the site uses `"/"`. The page path the conversions are for. Default `/`. At most 2048 characters.

> [accordion] Returns
>
> A `ListActiveConversionsResponse` (`Fetchski\AttractCmsLaravel\Data\ListActiveConversionsResponse`). The page’s conversions. Read its properties (`$listActiveConversions->conversions`): each says whether the site always sends it.
>
> **conversions** `Collection\<int, ListActiveConversionsResponseConversionsItem\>`
>
> **Always sent.** A list of `ListActiveConversionsResponseConversionsItem`.
>
> **ListActiveConversionsResponseConversionsItem (Fetchski\AttractCmsLaravel\Data\ListActiveConversionsResponseConversionsItem)**
>
> **id** `string`
>
> **Always sent.**
>
> **key** `string`
>
> **Always sent.** The Conversion’s key, sent to Google Analytics and Tag Manager as `conversion_key`.
>
> **counting** `Enums\\Counting|string`
>
> **Always sent.** One of `once`, `every`; a newer site may send others, so keep a fallback.
>
> **value** `?float`
>
> **Always sent, can be `null`.**
>
> **currency** `string`
>
> **Always sent.**
>
> **sendUserData** `bool`
>
> **Always sent.**
>
> **destinations** `Collection\<int, Enums\\Destinations|string\>`
>
> **Always sent.** The platforms the page sends this Conversion to. Each one of `google-ads`, `ga4`, `gtm`, `meta`, `tiktok`.
>
> **platforms** `array\<string, ListActiveConversionsResponseConversionsItemPlatformsValue\>`
>
> **Always sent.** A map of names to `ListActiveConversionsResponseConversionsItemPlatformsValue`. Per platform in `destinations`, what its tag needs: the event name (GA4, GTM, Meta, TikTok), or the Google Ads `send_to`.
>
> **ListActiveConversionsResponseConversionsItemPlatformsValue (Fetchski\AttractCmsLaravel\Data\ListActiveConversionsResponseConversionsItemPlatformsValue)**
>
> **event** `?string`
>
> **Sometimes sent:** `null` when the site leaves it out.
>
> **sendTo** `?string`
>
> **Sometimes sent:** `null` when the site leaves it out.
>
> **conversionId** `?string`
>
> **Sometimes sent:** `null` when the site leaves it out.
>
> **triggers** `ListActiveConversionsResponseConversionsItemTriggers`
>
> **Always sent.** A `ListActiveConversionsResponseConversionsItemTriggers`.
>
> **ListActiveConversionsResponseConversionsItemTriggers (Fetchski\AttractCmsLaravel\Data\ListActiveConversionsResponseConversionsItemTriggers)**
>
> Required.
>
> **forms** `Collection\<int, string\>`
>
> **Always sent.**
>
> **links** `Collection\<int, string\>`
>
> **Always sent.** Link patterns: a scheme (`tel:*`, `tel:+15550100100`), a full address (may end in `*`), a `/path` of this site, or a domain.
>
> **outbound** `bool`
>
> **Always sent.** Fires on any link that leaves the site.
>
> **downloads** `Collection\<int, string\>`
>
> **Always sent.** File extensions whose links fire it, e.g. `pdf`.
>
> **chat** `Collection\<int, Enums\\Chat|string\>`
>
> **Always sent.** Each one of `chat-started`, `lead-captured`.
>
> **pageView** `bool`
>
> **Always sent.** Whether viewing `path` fires it.

> [accordion] Errors
>
> Nothing to catch: the SDK retries what is safe, and Laravel logs and renders the rest (see [Errors and testing](https://docs.fetchski-attract.com/laravel/errors.md)).
>
> **SiteError** `5xx`
>
> The site failed (or something in front of it did). Its logs say why.
>
> **Retried first:** A 502, 503 or 504: yes, after 0.5 s then 1 s. A 500: no. **Read:** `siteMessage()`, `errorName()`, `data()`.
>
> **SiteUnreachable** `no answer`
>
> No answer: DNS, a refused connection, TLS, or the timeout (15 s per attempt by default).
>
> **Retried first:** Yes, after 0.5 s then 1 s. **Read:** `reason()`, `neverConnected()`.
>
> **RequestNotSent** `not sent`
>
> The client refused to send it (e.g. a path segment of `..`); the site never saw it.
>
> **Retried first:** No. **Read:** `reason()` (what to change).
>
> **SiteRequestFailed** `any other`
>
> Any other status, or a success whose JSON doesn’t match this SDK version’s types (update the SDK).
>
> **Retried first:** No. **Read:** `reason()`, `status()`.
>
> **UnknownSite** `setup`
>
> `Attract::site('acme')` named a slug that isn’t under `sites` in `config/fetchski-attract.php`.
>
> **Retried first:** No: nothing was sent. **Read:** `getMessage()`, `$e->slug`.
>
> **SiteConfigurationError** `setup`
>
> The site’s config entry is wrong: no `url`, a malformed `api_key`, a key filed under another slug, or no default site.
>
> **Retried first:** No: nothing was sent. **Read:** `getMessage()` (what to fix).

## Behavior

* **Retries:** a read is safe to repeat: the client retries it on no answer, a 502/503/504 and a 429.
* **Timeout:** 15 s per attempt by default; raise `timeout` in `config/fetchski-attract.php` for longer.

## Test it

It calls the route above with the SDK faked: the fake answers every call with a valid example, so nothing leaves your machine and no config or key is needed. Save it as `tests/Feature/ListActiveConversionsTest.php`, then run your tests:

```php tests/Feature/ListActiveConversionsTest.php theme={"dark"}
<?php

declare(strict_types=1);

namespace Tests\Feature;

use Fetchski\AttractCmsLaravel\Facades\Attract;
use Tests\TestCase;

final class ListActiveConversionsTest extends TestCase
{
    public function test_list_active_conversions(): void
    {
        Attract::fake();

        $this->getJson('/conversion/active')->assertOk();

        Attract::assertCalled('conversions.listActiveConversions');
    }
}
```

```bash Terminal theme={"dark"}
php artisan test
```

## Related

> [card] [List the enabled Conversions](https://docs.fetchski-attract.com/laravel/reference/conversions/list-conversion-definitions.md)
>
> `Attract::conversions()->listConversionDefinitions()`

> [card] [GET /conversion/active](https://docs.fetchski-attract.com/api-reference/conversions/conversions-the-page-can-fire-public.md)
>
> The endpoint this calls, in the API reference: the HTTP request and answer, and every rule the site checks.


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