# MTK Attribution → GoHighLevel custom fields (webhook forms)

Generated from the live MTK field map on every deploy. Fetch this file
each time you need it — do not copy the field list anywhere it can go
stale.

**Use this when** a form that is *not* a GoHighLevel form (the site's own
form, Webflow, custom HTML, …) sends its submissions to GoHighLevel
through an **Inbound Webhook** workflow. The MTK tag already puts the
`mtk_*` values on the form; this creates a contact custom field for each
one and maps the webhook into them, so nothing arrives and gets dropped.
For a GHL form embedded on the page, use
https://www.boggsmtk.com/products/attribution/docs/gohighlevel instead.

Human-readable version: https://www.boggsmtk.com/products/attribution/docs/gohighlevel/webhook-custom-fields

## For AI assistants — read this first

- **Take every field name from the table below.** Never from memory, and
  never shortened or prefixed. A name that is off by one character
  produces an empty field with no error anywhere.
- **Create all of them** unless the user tells you otherwise. A value
  that was never stored cannot be backfilled later.
- **What you can automate:** creating the custom fields, through
  GoHighLevel's API — only if you can make HTTP requests (code execution
  or a GoHighLevel connector) *and* the user gives you access. See
  "Creating the fields through the API".
- **What you cannot automate:** the folder (the API has no folder option
  for contact fields) and the Inbound Webhook workflow (GoHighLevel's
  Workflows API is a private beta; do not attempt it unless the user
  confirms their sub-account has it). Walk the user through those steps
  one at a time and wait for them to confirm each.
- **Without API access**, guide the user through the manual steps below,
  one group of fields at a time.
- **Confirm before you write.** Before creating anything, tell the user
  which sub-account and how many fields, and wait for their go-ahead.
- **The client's own map wins.** If they have exported their license's
  field map (dashboard → Tag config → Field map → Export CSV), create the
  fields from that instead — it may have fields switched off or added.

## Before you start

- The MTK tag is installed and the form carries the hidden `mtk_*`
  fields (https://www.boggsmtk.com/products/attribution/docs).
- The form, or the backend that receives it, can POST the submission as
  **JSON** — GoHighLevel's Inbound Webhook accepts JSON only. A
  form-encoded post must be converted first (in the site's endpoint,
  Zapier, Make, or similar).
- Every submission includes an **email or phone**; GoHighLevel needs one
  to create or update the contact.
- Each value is sent under its exact key, e.g. `mtk_first_source` — not
  `First Source` or `firstSource`.
- **Cost:** Inbound Webhook is a GoHighLevel premium trigger. Each
  sub-account gets 100 free executions once the agency enables premium
  triggers; after that every execution (one per submission) is billed at
  the agency's rate.

## The 45 fields

Create them in this order — first touch, then last touch, then IDs, then
insights — so the contact record reads as one story. Field names carry no
"MTK" prefix; the folder says what they are. Use Multi line where listed
(long values or line breaks) and Single line everywhere else; keep counts
as text, not Number.

### First touch

| # | Field name | Field type (UI) | dataType (API) | Webhook key |
|---|---|---|---|---|
| 1 | First Channel | Single line | `TEXT` | `mtk_first_channel` |
| 2 | First Source | Single line | `TEXT` | `mtk_first_source` |
| 3 | First Medium | Single line | `TEXT` | `mtk_first_medium` |
| 4 | First Campaign | Single line | `TEXT` | `mtk_first_campaign` |
| 5 | First Term | Single line | `TEXT` | `mtk_first_term` |
| 6 | First Content | Single line | `TEXT` | `mtk_first_content` |
| 7 | First Ad Placement | Single line | `TEXT` | `mtk_first_ad_placement` |
| 8 | First Landing Page | Single line | `TEXT` | `mtk_first_landing_page` |
| 9 | First Landing Page Group | Single line | `TEXT` | `mtk_first_landing_page_group` |
| 10 | First Query | Multi line | `LARGE_TEXT` | `mtk_first_query` |
| 11 | First Referrer | Multi line | `LARGE_TEXT` | `mtk_first_referrer` |

### Last touch

| # | Field name | Field type (UI) | dataType (API) | Webhook key |
|---|---|---|---|---|
| 12 | Last Channel | Single line | `TEXT` | `mtk_last_channel` |
| 13 | Last Source | Single line | `TEXT` | `mtk_last_source` |
| 14 | Last Medium | Single line | `TEXT` | `mtk_last_medium` |
| 15 | Last Campaign | Single line | `TEXT` | `mtk_last_campaign` |
| 16 | Last Term | Single line | `TEXT` | `mtk_last_term` |
| 17 | Last Content | Single line | `TEXT` | `mtk_last_content` |
| 18 | Last Ad Placement | Single line | `TEXT` | `mtk_last_ad_placement` |
| 19 | Last Landing Page | Single line | `TEXT` | `mtk_last_landing_page` |
| 20 | Last Landing Page Group | Single line | `TEXT` | `mtk_last_landing_page_group` |
| 21 | Last Query | Multi line | `LARGE_TEXT` | `mtk_last_query` |
| 22 | Last Referrer | Multi line | `LARGE_TEXT` | `mtk_last_referrer` |

### Click IDs & Meta cookies

| # | Field name | Field type (UI) | dataType (API) | Webhook key |
|---|---|---|---|---|
| 23 | gclid | Single line | `TEXT` | `mtk_gclid` |
| 24 | gbraid | Single line | `TEXT` | `mtk_gbraid` |
| 25 | wbraid | Single line | `TEXT` | `mtk_wbraid` |
| 26 | msclkid | Single line | `TEXT` | `mtk_msclkid` |
| 27 | fbclid | Single line | `TEXT` | `mtk_fbclid` |
| 28 | fbc | Single line | `TEXT` | `mtk_fbc` |
| 29 | fbp | Single line | `TEXT` | `mtk_fbp` |

### Insights

| # | Field name | Field type (UI) | dataType (API) | Webhook key |
|---|---|---|---|---|
| 30 | Journey String | Multi line | `LARGE_TEXT` | `mtk_journey_string` |
| 31 | Session Count | Single line | `TEXT` | `mtk_session_count` |
| 32 | Pageview Count | Single line | `TEXT` | `mtk_pageview_count` |
| 33 | Paid Touch Count | Single line | `TEXT` | `mtk_paid_touch_count` |
| 34 | Last Paid Touch | Single line | `TEXT` | `mtk_last_paid_touch` |
| 35 | Time Since Last Paid Touch | Single line | `TEXT` | `mtk_time_since_last_paid_touch` |
| 36 | Time To Conversion | Single line | `TEXT` | `mtk_time_to_conversion` |
| 37 | Page Path | Single line | `TEXT` | `mtk_page_path` |
| 38 | Page URL | Multi line | `LARGE_TEXT` | `mtk_page_url` |
| 39 | Conversion Unix | Single line | `TEXT` | `mtk_conversion_unix` |
| 40 | Conversion Datetime | Single line | `TEXT` | `mtk_conversion_datetime` |
| 41 | Custom Conversion Time | Single line | `TEXT` | `mtk_custom_conversion_time` |
| 42 | Browser | Single line | `TEXT` | `mtk_browser` |
| 43 | OS | Single line | `TEXT` | `mtk_os` |
| 44 | Device | Single line | `TEXT` | `mtk_device` |
| 45 | Tracking Health | Multi line | `LARGE_TEXT` | `mtk_tracking_health` |

### Optional — only if the client asks

Not in the standard set; everything they hold already arrives in the
fields above.

| # | Field name | Field type (UI) | dataType (API) | Webhook key |
|---|---|---|---|---|
| – | Journey JSON | Multi line | `LARGE_TEXT` | `mtk_journey_json` |
| – | Attribution Summary | Multi line | `LARGE_TEXT` | `mtk_attribution_summary` |

## Creating the fields through the API

Only with the user's go-ahead (see above). You need:

- **Location ID** — the sub-account's ID, the segment after `/location/`
  in its GoHighLevel URL.
- **A Private Integration token** for that sub-account (Settings → Private
  Integrations) with the scopes `locations/customFields.readonly` and
  `locations/customFields.write`. Suggest the user put it in an
  environment variable rather than paste it into the chat, and never echo
  it back or write it to a file.

Every request sends these headers:

```
Authorization: Bearer <token>
Version: 2021-07-28
Content-Type: application/json
```

1. **List what already exists:**
   `GET https://services.leadconnectorhq.com/locations/{locationId}/customFields?model=contact`.
   Compare names case-insensitively. Skip any field that already exists
   and tell the user which — reuse it rather than creating a duplicate.
2. **Create each missing field, in table order, one request at a time:**
   `POST https://services.leadconnectorhq.com/locations/{locationId}/customFields` with

   ```json
   { "name": "<Field name>", "dataType": "<dataType (API)>", "model": "contact" }
   ```

   A `201` returns `customField.id` and `customField.fieldKey` (for
   example `contact.first_source`).
3. **Stop on errors rather than retrying blindly.** `401`/`403` means the
   token or its scopes are wrong — ask the user to fix them. `422` means
   the request was rejected — show the user the response body.
4. **Report back** a table of Field name → `fieldKey`, plus anything
   skipped or failed. Then continue with the manual steps for the folder
   and the workflow.

## Manual steps

1. **Folder.** Settings → Custom Fields → Contact → Folders → Create
   folder → `MTK Attribution`. (If the fields were created through the
   API, edit each one and set its Folder — optional, but it keeps them
   together on the contact.)
2. **Fields** (skip if created through the API). Settings → Custom Fields
   → Contact → Create field, for each row above: Field type as listed,
   Field name exactly as listed, Folder `MTK Attribution`, then Create
   custom field.
3. **Trigger.** Automation → Workflows → create a workflow from scratch
   → add the **Inbound Webhook** trigger. Copy the webhook URL and point
   the form's submission (or its backend, Zapier, or Make) at it.
4. **Test request.** Send the request below (replace
   `YOUR_INBOUND_WEBHOOK_URL`). In the trigger, open **Mapping
   Reference**, pick that request (newest at the top), confirm the body
   shows the `mtk_*` keys, and **Save Trigger**. The request picked must
   contain every `mtk_*` key, or the missing ones won't appear in step 5.
5. **Map.** In the **Create / Update Contact** action that follows, map
   Email, Phone, and names, then set each MTK Attribution field to the
   matching key from the Inbound Webhook values — `mtk_first_channel` →
   First Channel, and so on down the table. Save and **Publish**.
6. **Verify.** Send the test request again and open the *MTK Webhook
   Test* contact. Every MTK field should read `TEST` plus its own name
   (First Source → `TEST First Source`). A different name means that one
   field is mapped to the wrong key; an empty field wasn't mapped or its
   key wasn't in the Mapping Reference; no contact means no email/phone
   or an unpublished workflow. Delete the test contact, then submit the
   real form from a test campaign URL and confirm real values arrive.

## Test request

```bash
curl -X POST "YOUR_INBOUND_WEBHOOK_URL" \
  -H "Content-Type: application/json" \
  -d '{
  "email": "mtk-webhook-test@example.com",
  "first_name": "MTK",
  "last_name": "Webhook Test",
  "mtk_first_channel": "TEST First Channel",
  "mtk_first_source": "TEST First Source",
  "mtk_first_medium": "TEST First Medium",
  "mtk_first_campaign": "TEST First Campaign",
  "mtk_first_term": "TEST First Term",
  "mtk_first_content": "TEST First Content",
  "mtk_first_ad_placement": "TEST First Ad Placement",
  "mtk_first_landing_page": "TEST First Landing Page",
  "mtk_first_landing_page_group": "TEST First Landing Page Group",
  "mtk_first_query": "TEST First Query",
  "mtk_first_referrer": "TEST First Referrer",
  "mtk_last_channel": "TEST Last Channel",
  "mtk_last_source": "TEST Last Source",
  "mtk_last_medium": "TEST Last Medium",
  "mtk_last_campaign": "TEST Last Campaign",
  "mtk_last_term": "TEST Last Term",
  "mtk_last_content": "TEST Last Content",
  "mtk_last_ad_placement": "TEST Last Ad Placement",
  "mtk_last_landing_page": "TEST Last Landing Page",
  "mtk_last_landing_page_group": "TEST Last Landing Page Group",
  "mtk_last_query": "TEST Last Query",
  "mtk_last_referrer": "TEST Last Referrer",
  "mtk_gclid": "TEST gclid",
  "mtk_gbraid": "TEST gbraid",
  "mtk_wbraid": "TEST wbraid",
  "mtk_msclkid": "TEST msclkid",
  "mtk_fbclid": "TEST fbclid",
  "mtk_fbc": "TEST fbc",
  "mtk_fbp": "TEST fbp",
  "mtk_journey_string": "TEST Journey String",
  "mtk_session_count": "TEST Session Count",
  "mtk_pageview_count": "TEST Pageview Count",
  "mtk_paid_touch_count": "TEST Paid Touch Count",
  "mtk_last_paid_touch": "TEST Last Paid Touch",
  "mtk_time_since_last_paid_touch": "TEST Time Since Last Paid Touch",
  "mtk_time_to_conversion": "TEST Time To Conversion",
  "mtk_page_path": "TEST Page Path",
  "mtk_page_url": "TEST Page URL",
  "mtk_conversion_unix": "TEST Conversion Unix",
  "mtk_conversion_datetime": "TEST Conversion Datetime",
  "mtk_custom_conversion_time": "TEST Custom Conversion Time",
  "mtk_browser": "TEST Browser",
  "mtk_os": "TEST OS",
  "mtk_device": "TEST Device",
  "mtk_tracking_health": "TEST Tracking Health"
}'
```

## When MTK adds a field

It appears in this file on the next deploy. Create it in GoHighLevel the
same way, re-select the Mapping Reference in the trigger with a request
that carries the new key, and map it in the action. Until it is mapped,
the value reaches the webhook and is dropped.
