> For the complete documentation index, see [llms.txt](https://popin.gitbook.io/popin-developer-hub/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://popin.gitbook.io/popin-developer-hub/passing-campaign-data-via-popin-and-webhook-meta.md).

# Passing Campaign Data via Popin & Webhook (Meta)

Popin supports passing campaign and tracking data (such as UTM parameters and custom identifiers) when opening the widget.

This data is automatically included in webhook payloads under the `properties.meta` object, ensuring consistency across all events.

***

### 1. Passing Campaign Data

You can attach campaign details when opening Popin using the `campaign` object:

```javascript
Popin('open', {
  campaign: {
    utm_source: "google",
    utm_medium: "cpc",
    utm_campaign: "summer_sale",
    utm_term: "buy+hotel+rooms",
    utm_content: "banner_ad_1"
  }
});
```

***

### 2. Supported Fields

| Key            | Type   | Description                                                        |
| -------------- | ------ | ------------------------------------------------------------------ |
| `utm_source`   | string | Identifies the traffic source (e.g., google, facebook).            |
| `utm_medium`   | string | Identifies the medium (e.g., cpc, email, referral).                |
| `utm_campaign` | string | Campaign name (e.g., summer\_sale).                                |
| `utm_term`     | string | Paid keyword or search term.                                       |
| `utm_content`  | string | Differentiates ads/content (e.g., banner\_ad\_1).                  |
| Custom fields  | any    | Additional keys are supported (e.g., `partner_id`, `creative_id`). |

***

### 3. Example with Custom Data

You can also include custom identifiers such as `partner_id` or `creative_id`:

```javascript
Popin('open', {
  campaign: {
    utm_source: "linkedin",
    utm_medium: "social",
    utm_campaign: "b2b_launch",
    partner_id: "12345",
    creative_id: "banner_blue"
  }
});
```

***

### 4. Webhook Delivery

All campaign data is mapped into the `properties.meta` object of webhook payloads.

#### Example Payload (`popin_user_captured`)

```json
{
  "event": "popin_user_captured",
  "user_id": "3ab7634bb5f3a7544fd16ca0e5107b07",
  "email": null,
  "country_code": "+91",
  "phone_number": "9792521396",
  "full_phone_number": "+919792521396",
  "properties": {
    "customer_name": "Anubhav Jaiswal",
    "customer_email": null,
    "customer_country_code": "+91",
    "customer_phone_number": "9792521396",
    "url": "https://meralda.scalenext.io/product-detail/estelle-clover-baguette-ring",
    "product": "Estelle Clover Baguette Ring",
    "meta": {
      "utm_source": "google",
      "utm_medium": "cpc",
      "utm_campaign": "summer_sale",
      "utm_term": "buy+hotel+rooms",
      "utm_content": "banner_ad_1"
    }
  },
  "timestamp": "2025-09-17T14:41:02+00:00"
}
```

***

### 5. Notes

* All campaign parameters passed via `Popin('open', { campaign: {...} })` are forwarded into `properties.meta`.
* Custom keys (e.g., `partner_id`, `creative_id`) are supported and appear under `meta`.
* This mapping is consistent across all webhook events, including:
  * `popin_user_captured`
  * `popin_call_successful`
  * `popin_call_rated`
* If no campaign data is passed, the `meta` object will still exist but may be empty.

***
