Python
from dub import Dub
with Dub(
token="DUB_API_KEY",
) as d_client:
res = d_client.track.lead(request={
"click_id": "<id>",
"event_name": "Sign up",
"customer_external_id": "<id>",
})
# Handle response
print(res)declare(strict_types=1);
require 'vendor/autoload.php';
use Dub;
use Dub\Models\Operations;
$sdk = Dub\Dub::builder()
->setSecurity(
'DUB_API_KEY'
)
->build();
$request = new Operations\TrackLeadRequestBody(
clickId: '<id>',
eventName: 'Sign up',
customerExternalId: '<id>',
);
$response = $sdk->track->lead(
request: $request
);
if ($response->object !== null) {
// handle response
}package main
import(
"context"
dubgo "github.com/dubinc/dub-go"
"github.com/dubinc/dub-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := dubgo.New(
dubgo.WithSecurity("DUB_API_KEY"),
)
res, err := s.Track.Lead(ctx, &operations.TrackLeadRequestBody{
ClickID: "<id>",
EventName: "Sign up",
CustomerExternalID: "<id>",
})
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}require 'dub'
Models = ::OpenApiSDK::Models
s = ::OpenApiSDK::Dub.new(
security: Models::Shared::Security.new(
token: 'DUB_API_KEY',
),
)
req = Models::Operations::TrackLeadRequestBody.new(
click_id: '<id>',
event_name: 'Sign up',
customer_external_id: '<id>',
)
res = s.track.lead(request: req)
unless res.nil?
# handle response
endimport { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.track.lead();
console.log(result);
}
run();curl --request POST \
--url https://api.dub.co/track/lead \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"clickId": "<string>",
"eventName": "Sign up",
"customerExternalId": "<string>",
"customerName": null,
"customerEmail": null,
"customerAvatar": null,
"mode": "async",
"eventQuantity": 123,
"metadata": null
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
clickId: '<string>',
eventName: 'Sign up',
customerExternalId: '<string>',
customerName: null,
customerEmail: null,
customerAvatar: null,
mode: 'async',
eventQuantity: 123,
metadata: null
})
};
fetch('https://api.dub.co/track/lead', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.dub.co/track/lead")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"clickId\": \"<string>\",\n \"eventName\": \"Sign up\",\n \"customerExternalId\": \"<string>\",\n \"customerName\": null,\n \"customerEmail\": null,\n \"customerAvatar\": null,\n \"mode\": \"async\",\n \"eventQuantity\": 123,\n \"metadata\": null\n}")
.asString();{
"click": {
"id": "<string>"
},
"link": {
"id": "<string>",
"domain": "<string>",
"key": "<string>",
"shortLink": "<string>",
"url": "<string>",
"partnerId": "<string>",
"programId": "<string>",
"tenantId": "<string>",
"externalId": "<string>"
},
"customer": {
"name": "<string>",
"email": "<string>",
"avatar": "<string>",
"externalId": "<string>"
}
}{
"error": {
"code": "bad_request",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#bad-request"
}
}{
"error": {
"code": "unauthorized",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#unauthorized"
}
}{
"error": {
"code": "forbidden",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#forbidden"
}
}{
"error": {
"code": "not_found",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#not-found"
}
}{
"error": {
"code": "conflict",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#conflict"
}
}{
"error": {
"code": "invite_expired",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#invite-expired"
}
}{
"error": {
"code": "unprocessable_entity",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#unprocessable-entity"
}
}{
"error": {
"code": "rate_limit_exceeded",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#rate-limit_exceeded"
}
}{
"error": {
"code": "internal_server_error",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#internal-server_error"
}
}Conversions
Track a lead
Track a lead for a short link.
POST
/
track
/
lead
Python
from dub import Dub
with Dub(
token="DUB_API_KEY",
) as d_client:
res = d_client.track.lead(request={
"click_id": "<id>",
"event_name": "Sign up",
"customer_external_id": "<id>",
})
# Handle response
print(res)declare(strict_types=1);
require 'vendor/autoload.php';
use Dub;
use Dub\Models\Operations;
$sdk = Dub\Dub::builder()
->setSecurity(
'DUB_API_KEY'
)
->build();
$request = new Operations\TrackLeadRequestBody(
clickId: '<id>',
eventName: 'Sign up',
customerExternalId: '<id>',
);
$response = $sdk->track->lead(
request: $request
);
if ($response->object !== null) {
// handle response
}package main
import(
"context"
dubgo "github.com/dubinc/dub-go"
"github.com/dubinc/dub-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := dubgo.New(
dubgo.WithSecurity("DUB_API_KEY"),
)
res, err := s.Track.Lead(ctx, &operations.TrackLeadRequestBody{
ClickID: "<id>",
EventName: "Sign up",
CustomerExternalID: "<id>",
})
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}require 'dub'
Models = ::OpenApiSDK::Models
s = ::OpenApiSDK::Dub.new(
security: Models::Shared::Security.new(
token: 'DUB_API_KEY',
),
)
req = Models::Operations::TrackLeadRequestBody.new(
click_id: '<id>',
event_name: 'Sign up',
customer_external_id: '<id>',
)
res = s.track.lead(request: req)
unless res.nil?
# handle response
endimport { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.track.lead();
console.log(result);
}
run();curl --request POST \
--url https://api.dub.co/track/lead \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"clickId": "<string>",
"eventName": "Sign up",
"customerExternalId": "<string>",
"customerName": null,
"customerEmail": null,
"customerAvatar": null,
"mode": "async",
"eventQuantity": 123,
"metadata": null
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
clickId: '<string>',
eventName: 'Sign up',
customerExternalId: '<string>',
customerName: null,
customerEmail: null,
customerAvatar: null,
mode: 'async',
eventQuantity: 123,
metadata: null
})
};
fetch('https://api.dub.co/track/lead', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.dub.co/track/lead")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"clickId\": \"<string>\",\n \"eventName\": \"Sign up\",\n \"customerExternalId\": \"<string>\",\n \"customerName\": null,\n \"customerEmail\": null,\n \"customerAvatar\": null,\n \"mode\": \"async\",\n \"eventQuantity\": 123,\n \"metadata\": null\n}")
.asString();{
"click": {
"id": "<string>"
},
"link": {
"id": "<string>",
"domain": "<string>",
"key": "<string>",
"shortLink": "<string>",
"url": "<string>",
"partnerId": "<string>",
"programId": "<string>",
"tenantId": "<string>",
"externalId": "<string>"
},
"customer": {
"name": "<string>",
"email": "<string>",
"avatar": "<string>",
"externalId": "<string>"
}
}{
"error": {
"code": "bad_request",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#bad-request"
}
}{
"error": {
"code": "unauthorized",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#unauthorized"
}
}{
"error": {
"code": "forbidden",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#forbidden"
}
}{
"error": {
"code": "not_found",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#not-found"
}
}{
"error": {
"code": "conflict",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#conflict"
}
}{
"error": {
"code": "invite_expired",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#invite-expired"
}
}{
"error": {
"code": "unprocessable_entity",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#unprocessable-entity"
}
}{
"error": {
"code": "rate_limit_exceeded",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#rate-limit_exceeded"
}
}{
"error": {
"code": "internal_server_error",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#internal-server_error"
}
}Body
application/json
The unique ID of the click that the lead conversion event is attributed to. You can read this value from dub_id cookie. [For deferred lead tracking]: If an empty string is provided, Dub will try to find an existing customer with the provided customerExternalId and use the clickId from the customer if found.