Chapter 7

Send events to your systems

Report what people do in your app, and pass it on as it happens.

  1. Report events from your app

    Call track from the SDK whenever something worth measuring happens, such as a sign-up or a purchase. Event names can use letters, digits and _ - . :

    // iOS
    try await link.track("purchase", revenue: 19.99, currency: "USD")
    
    // Android
    link.track("purchase", revenue = 19.99, currency = "USD") { }
  2. Understand revenue

    Send the amount with a three-letter currency code. Reports total US dollars only. Other currencies are saved and sent on to your destinations, but are not added to the revenue column.

  3. Create a webhook

    Open Integrations, then Webhooks, and choose New webhook. Select the app, enter your https:// address, and list the events you want, or leave the list empty to receive everything. The event named install is sent on first launch.

  4. Verify each request

    Copy the signing secret from the webhook page. Every request has an X-Deepberth-Signature header containing a timestamp and a signature. Compute an HMAC-SHA256 of the timestamp, a period, and the raw body, then compare it with v1.

    X-Deepberth-Signature: t=1762600000,v1=5f8a...
    
    expected = HMAC_SHA256(secret, t + "." + raw_body)
  5. Create a postback

    Open Integrations, then Postbacks, and choose New postback. Enter the address your partner gave you with the values you need in curly brackets, then list which of your events to send and what to call them.

    https://tracker.example.com/pb?event={partner_event}&click={click_id}&value={revenue}
  6. Check that they arrive

    Open Reports and find Webhook and postback attempts. A destination that fails is retried after 30 seconds, 2 minutes, 10 minutes, 1 hour and 6 hours. Your server should return a 2xx status quickly.