---
layout: page_v2
title: Vendor Billing in Prebid.js
description: Documentation on how to add Vendor Billing in Prebid.js
sidebarType: 1
---

# Vendor Billing in Prebid.js

{:.no_toc}

Prebid.js now supports a new event type: **Billable Event**. Billable events allow **Real Time Data (RTD)** modules to signal that their system calculated that a billing event occurred. Billable  events are trackable by analytics adapters as well as publishers to track and aggregate billing data.

## Emitting Events

In order to emit events, **RTD** modules simply need to utilize the existing Events system already integrated into Prebid.js. A new event, **BILLABLE_EVENT**, is registered inside the constants.json file for usage.

At this time there are limited requirements about the contents of billable events. However, it should be expected that partners who choose to leverage billable events may have unique requirements or implementations that will be documented individually, including adding additional parameters to the events as they see fit.

### Event Payload Parameters

There are two parameters that emitters of this event must supply. Other parameters may be supplied as desired by the application.

{: .table .table-bordered .table-striped }
| **Required Parameter**  |  **Type** |  **Definition** |
|----------------+-----------+-----------------|
|  vendor |  string | Contains the unique name of the vendor, and will be used to identify which vendor triggered a given event.  |
|  billingId |  UUID |  A unique UUID associated with a given billing event.  Generated by the vendor. |

For example, a RTD module could emit an event like this:

```javascript
events.emit(CONSTANTS.EVENTS.BILLABLE_EVENT, {
  vendor: 'vendorA',
  billingId: generateUUID(),
  type: 'ad_request',
  transactionId: transactionId,
  auctionId: auctionId
})
```

It is expected that vendors will not emit duplicate events.

## Analytics Adapter Interface

[Analytics Adapters](/dev-docs/integrate-with-the-prebid-analytics-api.html) just listen for the **BILLABLE_EVENT**. It is assumed that analytics adapters and their downstream reporting handles their own tracking of events any validation of the contract between vendors and publishers.

```javascript
switch (eventType) {
  // ...
  case BILLABLE_EVENT:
  // ...
```

## Related Reading

- [pbjs.getEvents()](/dev-docs/publisher-api-reference/getEvents.html)
- [Real Time Data modules](/dev-docs/add-rtd-submodule.html)
- [Analytics Adapters](/dev-docs/integrate-with-the-prebid-analytics-api.html)
