The event object

Voucherify distinguishes two types of events - custom and internal. Both are presented in the same Event structure.

Custom Events

Custom Events are actions taken by your customers. They’re best suited for tracking high-value customer interactions with your application. Logging a custom event can trigger any number of distributions, and enables the segmentation filters around the recency and frequency of that event.

With Custom Event metadata field, Voucherify allows you to set properties on custom events. These properties can then be used for further qualifying trigger conditions, increasing personalization in messaging, and generating more sophisticated analytics through raw data export.

The Custom Events are directly linked to the customers' resources from Voucherify. It means that each event gets a connection to a customer.

📘

An example

If an e-commerce application wanted to send a message to a user when he/she abandons their cart, the custom event could additionally improve its target audience and allow for increased distribution personalization by adding a Custom Event of the value of customers’ order.

Internal Voucherify Events

Moreover, Events are our way of letting you know when something interesting happens in your project. When an interesting event occurs, we create a new Event object. For example, when a redemption succeeds, we create a redemption.succeeded event.

Note that many API requests may cause multiple events to be created. For example, if you create a new redemption for a new customer not existing yet in Voucherify, you will receive both a customer.created event and a redemption.succeeded event.

The events occur when the state of another API resource changes and the state of that resource at the time of the change is embedded in the data field of the event.

Types of internal events

Campaign

campaign.validation_rules.created
campaign.created
campaign.disabled
campaign.export_mailchimp_scheduled
campaign.export_mailchimp_done
campaign.validation_rules.deleted
campaign.validation_rules.updated
campaign.updated
campaign.deleted
campaign.export_mailchimp_failed
campaign.enabled

Voucher

voucher.validation.succeeded
voucher.updated
voucher.enabled
voucher.gift.balance_added
voucher.validation_rules.updated
voucher.published
voucher.validation_rules.deleted
voucher.disabled
voucher.validation.failed
voucher.validation_rules.created
voucher.deleted
voucher.created

Redemption

redemption.succeeded
redemption.failed
redemption.rollback.failed
redemption.rollback.succeeded

Customer

customer.rewarded
customer.rewarded.loyalty_points
customer.sms.sent
customer.email.failed
customer.deleted
customer.created
customer.updated
customer.segment.left
customer.sms.failed
customer.segment.entered
customer.email.sent

Order

order.canceled
order.created
order.updated
order.paid

Product

product.updated
product.created
product.deleted

SKU

sku.updated
sku.created
sku.deleted

Distribution

distribution.sms.failed
distribution.sms.sent
distribution.email.sent
distribution.email.failed

Export

export.done
export.scheduled
export.failed
export.deleted

Webhooks

Voucherify also has a separate system for sending the event objects directly to an endpoint at your end (server). We called that mechanism webhooks. They are managed in your project settings.

Attribute

Description

Example

id
string

event_xjGas2mI2PduFFPL2NAcFeHkHfLn3H

object
string

Type of the object represented by JSON. Value is event.

created_at
string, ISO 8601 date format

Time at which the object was created.

2016-11-16T14:14:31Z

type
string

Description of the event

view_pricing_page
redemption.succeeded

data.object
object

The object containing data associated with the event. It can be a customer, redemption or any other type of object which is a source of the event. In this object structure, you can also find a property related_object which contains values presenting any other resource connected to the event.

For Custom Event the structure of child attributes is constant:

  • customer (object) - The object presenting a profile of the related customer who performed an action.

  • metadata (object) - A set of key/value pairs that you can attach to a custom event object. It can be useful for storing additional information about the event in a structured format.

"data": {
  "object": {
    "customer": {
      "id": "cust_OtHDKrv5sJrjd8aYBYZ6AOIF",
      "name": "Gustav Purpleson",
      "object": "customer",
      "source_id": "[email protected]",
      "created_at": 1510834859417,
      "updated_at": 1510835106559
    },
    "metadata": {
      "lang": "en",
      "test": true,
      "page": "http://main.io"
    }
  }
}

metadata
object

A set of key/value pairs that Voucherify attaches to a custom event object. It is a set of additional system information about the event in a structured format.

{
  "id": "event_ehkvgZFgSePlb95SH3JJulkApy9Kg9",
  "object": "event",
  "created_at": "2017-11-16T14:45:34.181Z",
  "type": "redemption.succeeded",
  "data": {
    "object": {
      "id": "r_mist0IpebikTaRdxiOGI2IhL",
      "date": "2017-11-16T14:45:32.733Z",
      "order": {
        "id": "ord_AhDlR13vQE5ino95P2NIABBN",
        "items": [
          {
            "object": "order_item",
            "sku_id": null,
            "quantity": 1,
            "source_id": null,
            "product_id": "iphone8"
          }
        ],
        "amount": 50000,
        "object": "order",
        "status": "CREATED",
        "customer": {
          "id": "cust_fJPsoub5ITJnIEVO3v9whrP9",
          "object": "customer"
        },
        "metadata": null,
        "referrer": null,
        "source_id": null,
        "created_at": "2017-11-16T14:45:32.023Z",
        "updated_at": null,
        "discount_amount": 2000
      },
      "object": "redemption",
      "result": "SUCCESS",
      "voucher": {
        "code": "2017-goX-aH",
        "gift": null,
        "type": "DISCOUNT_VOUCHER",
        "object": "voucher",
        "campaign": "SteffenTest",
        "discount": {
          "type": "AMOUNT",
          "amount_off": 2000
        },
        "is_referral_code": false
      },
      "customer": {
        "id": "cust_fJPsoub5ITJnIEVO3v9whrP9",
        "object": "customer"
      },
      "metadata": {
        "city": "London1"
      },
      "customer_id": "cust_fJPsoub5ITJnIEVO3v9whrP9",
      "tracking_id": "track_3tM7KR57bbeIRtMcvpKYr2aAOrCpYBDZ",
      "related_object_type": "voucher"
    },
    "previous_attributes": {}
  },
  "metadata": {
    "source": "API"
  }
}