# Fixed Links (Manage · `Src\Marketing\FixedLink`)

**Context:** Manage portal + one public route · **Routes:** `manage.marketing.fixed-links.*`
(`/manage/marketing/fixed-links`) and the public `fixed-link.redirect` (`GET /link/{slug}`) ·
**Permissions:** `view-marketing` opens the page; `manage-marketing` creates / edits / deletes ·
**Nav:** a tab of the **Traffics** section (`SectionTabs` `traffics`: Campaign Performance → **Fixed Links** → Payment);
the Traffics sidebar entry lists `/manage/marketing/fixed-links` in its `prefixes`.

## What it does

An admin creates a public URL whose last part they name — `https://propertylabglobal.com/link/{slug}` — and
chooses where it goes. The destination can be changed at any time while the URL stays the same, so an ad, a QR
code or a bio link never has to be edited when the landing page moves. (Editing a Meta ad's URL restarts its
learning phase; re-pointing a fixed link does not touch the ad.) Each link counts its clicks.

## How it works

- **Redirect** — `Main\FixedLinkRedirectController@show` finds an **Active** link by slug (lowercased, so
  `/link/MasterClass` works), adds one to `click_count` + stamps `last_clicked_at`, and answers **302** (never 301:
  a browser keeps a 301 forever, and the destination is meant to change). Unknown / inactive / deleted → the site
  home (`landing`), so a shared link never dead-ends.
- **The visitor's query string is carried over** — `FixedLink::mergeQuery()`, fed the RAW `QUERY_STRING`:
  1. a parameter the visitor brings **replaces** the destination's own parameter of the same name;
  2. any parameter whose value is still an unfilled Meta macro (`{{campaign.name}}`, `{{ad.id}}` …) is **dropped**;
  3. raw text is kept as-is (no decode / re-encode); a `#fragment` stays last.

  This is what keeps ad attribution working through the hop: the landing page records `utm_*`, `fbclid`,
  `campaign_id` / `adset_id` / `ad_id` from ITS query string (`LandingController`), and `LandingSignups` counts
  sign-ups by those ids for CPL.
- **Why macros must be in the AD, not the destination.** Meta fills `{{…}}` only in the URL the ad itself carries.
  A destination stored here is invisible to Meta, so its macros would reach the landing page as literal text —
  and be recorded as a campaign id — which is why rule 2 drops them. When a destination holds macros, the page
  shows **"URL for the Meta ad"** (`resources/js/utils/fixedLinkAdUrl.js`): the fixed link plus exactly those macro
  parameters. Paste that into the ad; Meta fills them on each click and the redirect passes them on. Static
  parameters (`utm_source=meta`) stay in the destination, editable later.
- **Slugs** — lowercase letters, digits, single hyphens (`FixedLink::SLUG_PATTERN`). Unique among **live** links
  only (the column has a plain index, not a unique one), so a deleted link's slug can be reused. Changing a slug
  is allowed but the edit modal warns that the old URL stops working. `link` is in the funnel
  `RESERVED_SLUGS`, and the route is declared above the `{slug}` / `{funnel}/{slot}` landing catch-alls.
- Create / edit / delete happen in a modal on the index (`FixedLinkFormModal`); on create the slug follows the
  name until the admin types their own. Status (Active / Inactive) is a plain field in `update()`.

## Table — `fixed_links`

| Column | Notes |
|---|---|
| `id`, `uuid` | key model (`HasUuid`; uuid in URLs) |
| `name` | internal label, never shown to visitors |
| `slug` | the `{slug}` in `/link/{slug}`; indexed, unique among non-deleted rows (validated) |
| `destination_url` | text; any `http(s)` URL with a dotted host, no spaces — Laravel's `url` rule is NOT used because it rejects `{{…}}` |
| `status` | `FixedLink::STATUS_INACTIVE` (1) / `STATUS_ACTIVE` (2) |
| `click_count`, `last_clicked_at` | tallied on every redirect (bots and link-preview fetches included — a rough figure; Meta's own link clicks live on Campaign Performance) |
| `created_by` / `updated_by` / `deleted_by`, timestamps, `deleted_at` | `RecordsBlame` + soft delete |

## Related files

**Backend**
- [`src/Marketing/FixedLink.php`](/src/Marketing/FixedLink.php) — model, `mergeQuery()`, `isMacro()`, `fixed_url`
- [`src/Marketing/Repositories/FixedLinkRepository.php`](/src/Marketing/Repositories/FixedLinkRepository.php) — create / update / delete / `recordClick`
- [`app/Http/Controllers/Manage/Marketing/FixedLinksController.php`](/app/Http/Controllers/Manage/Marketing/FixedLinksController.php)
- [`app/Http/Controllers/Main/FixedLinkRedirectController.php`](/app/Http/Controllers/Main/FixedLinkRedirectController.php)
- [`app/Http/Requests/Manage/Marketing/FixedLinks/StoreRequest.php`](/app/Http/Requests/Manage/Marketing/FixedLinks/StoreRequest.php) + `UpdateRequest.php`

**Frontend**
- [`resources/js/Pages/Manage/Marketing/FixedLinks/Index.vue`](/resources/js/Pages/Manage/Marketing/FixedLinks/Index.vue)
- [`resources/js/Pages/Manage/Marketing/FixedLinks/Partials/FixedLinkFormModal.vue`](/resources/js/Pages/Manage/Marketing/FixedLinks/Partials/FixedLinkFormModal.vue)
- [`resources/js/utils/fixedLinkAdUrl.js`](/resources/js/utils/fixedLinkAdUrl.js) — the "URL for the Meta ad" helper
- [`resources/js/Components/SectionTabs.vue`](/resources/js/Components/SectionTabs.vue) (`traffics` tab), [`resources/js/Layouts/ManageLayout.vue`](/resources/js/Layouts/ManageLayout.vue) (Traffics `prefixes`)

**Migrations** — `database/migrations/2026_11_10_120000_create_fixed_links_table.php`

**Routes** — `routes/web.php` (`manage.marketing.fixed-links.*`, inside the `marketing` group), `routes/main.php` (`link/{slug}`)

**Tests** — [`tests/Feature/Marketing/FixedLinkTest.php`](/tests/Feature/Marketing/FixedLinkTest.php)

Related: [Marketing — Traffics](/docs/modules_handbook/manage/meta-ads/marketing/readMe.md) ·
[WhatsApp CTA links](/docs/modules_handbook/manage/messages/whatsapp/cta_link.md) (the `/wa/{slug}` short link this mirrors)
