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

# Conversions

> Credit purchases and sign-ups to the short link that brought the visitor.

Every short-link click adds a `kid` query parameter on the destination. A snippet on the client site stores that click in a first-party cookie and later credits a purchase or sign-up to the same click.

Attribution is last-click: the most recent TrimYourl click in the visitor's browser, if it is still inside the attribution window.

## 1. Paste the snippet

Open **Settings → Conversions**. Copy the snippet into the destination site's `<head>`. In Google Tag Manager, add it as a Custom HTML tag that fires on all pages.

```html theme={null}
<!-- TrimYourl conversion tracking -->
<script>window.trimyourl=window.trimyourl||function(){(trimyourl.q=trimyourl.q||[]).push(arguments)};</script>
<script async src="https://trimyourl.com/c/t.js" data-client="trk_YOUR_KEY" data-days="30"></script>
```

`data-client` is the workspace tracking key. `data-days` should match the attribution window you save in Settings (1–90 days). Paste the snippet again after you change the window so the cookie lifetime matches.

> [!NOTE]
>
> Browsers that limit cookies, such as Safari, often keep the click for about 7 days. A conversion after that cookie is gone cannot be credited.

## 2. Fire events

On the thank-you page or after a sign-up form:

```javascript theme={null}
trimyourl("track", "purchase", { value: 49.99, currency: "USD", orderId: "1001" });
trimyourl("track", "sign_up");
```

Event names are yours. `purchase` and `sale` count as sales; other names count as leads. An `orderId` stops a reloaded thank-you page from counting twice.

## 3. Test

Open a short link, then trigger a conversion on the site. Add `data-debug` to the script tag, or run `trimyourl("debug")` in the console, to see each event. Credited rows show up under Settings → Conversions.

## Webhook

Owners can set a conversion webhook URL in Settings. On each credited event TrimYourl POSTs JSON to that URL. See [Conversion webhooks](https://docs.trimyourl.com/api-reference/webhooks.md).

## Server-side

If the snippet cannot run, `POST /api/v1/convert` with the same fields. See [Track a conversion](https://docs.trimyourl.com/api-reference/conversions/track-a-conversion).


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