POST
/
track
/
sale
require 'dub'

s = ::OpenApiSDK::Dub.new(
      security: ::OpenApiSDK::Shared::Security.new(
        token: "DUB_API_KEY",
      ),
    )

req = ::OpenApiSDK::Operations::TrackSaleRequestBody.new(
  external_id: "<id>",
  amount: 996_500,
  payment_processor: ::OpenApiSDK::Operations::PaymentProcessor::CUSTOM,
  event_name: "Invoice paid",
  lead_event_name: "Cloned template 1481267",
)

res = s.track.sale(req)

if ! res.object.nil?
  # handle response
end
{
  "eventName": "<string>",
  "customer": {
    "id": "<string>",
    "name": "<string>",
    "email": "<string>",
    "avatar": "<string>",
    "externalId": "<string>"
  },
  "sale": {
    "amount": 123,
    "currency": "<string>",
    "paymentProcessor": "<string>",
    "invoiceId": "<string>",
    "metadata": {}
  }
}

Conversions endpoints require a Business plan subscription or higher.

Authorizations

Authorization
string
header
required

Default authentication mechanism

Body

application/json
externalId
string
required

The unique ID of the customer in your system. Will be used to identify and attribute all future events to this customer.

Maximum length: 100
amount
integer
required

The amount of the sale in cents.

Required range: x >= 0
paymentProcessor
enum<string>
required

The payment processor via which the sale was made.

Available options:
stripe,
shopify,
polar,
paddle,
custom
eventName
string
default:Purchase

The name of the sale event.

Maximum length: 255
Example:

"Invoice paid"

invoiceId
string | null

The invoice ID of the sale. Can be used as a idempotency key – only one sale event can be recorded for a given invoice ID.

currency
string
default:usd

The currency of the sale. Accepts ISO 4217 currency codes.

leadEventName
string | null

The name of the lead event that occurred before the sale (case-sensitive). This is used to associate the sale event with a particular lead event (instead of the latest lead event, which is the default behavior).

Example:

"Cloned template 1481267"

metadata
object | null

Additional metadata to be stored with the sale event. Max 10,000 characters.

Response

200
application/json
A sale was tracked.
eventName
string
required
customer
object | null
required
sale
object | null
required