Skip to content

Instantly share code, notes, and snippets.

@zsy715
Last active April 18, 2019 16:47
Show Gist options
  • Save zsy715/17859e4065a45bbba15370dc6a3399e0 to your computer and use it in GitHub Desktop.
Save zsy715/17859e4065a45bbba15370dc6a3399e0 to your computer and use it in GitHub Desktop.
Braze event in magento

Braze Usertrack Events in Magento

Recently, Birchbox moved non-transactional emails from Selligent to Braze(tech doc). This page is mainly a quick reference of braze events being sent within Magento.
All Braze configurations(endpoint url, api key, threshold etc) could be found in magento admin UI. They are under System -> Configuration -> Birchbox APIs.
relevant code is here

Braze event post helper

In Magento, there is a helper class(EventPost.php) which includes all the fundamental methods(read configurations, send post request to Braze endpoint) for braze event post.
Any further implementations should also go to this class to avoid duplicated code.

There are a couple of Braze user track events sent from Magento

validate order:

There two places where we send user track purchases object to Braze endpoint.

payload:
{
  "api_key": "",
  "purchases": [
    {
      "external_id": "",
      "properties": {
        "product_type": "",
        "sku": "",
        "name": "",//order item name
        "qty":
      },
      "time": "", //ISO-8601
      "name": "expired_gift",
      "product_id": ,//order item id
      "price": ,
      "currency": 
    }
  ]
}

expired gift:code

payload:
{
  "api_key": "",
  "events": [
    {
      "external_id": "",
      "properties": {},
      "time": "", //ISO-8601
      "name": "expired_gift"
    }
  ]
}

order is shipped: code

payload:
{
  "api_key": "",
  "events":[
    {
      "external_id": "",
      "properties": {},
      "time": "",//ISO-8601
      "name": "fullsize_has_shipped"
    }
  ],
}

check for vip dollar spent: code

There is check_for_vips.php in the same directory.It is an older version of check_for_vips_dollars_spent.php so it would possibly be removed later but you could refer code here

payload:
{
  "api_key": "",
  "events": [
    {
      "external_id": "",
      "properties": {},
      "time": "", //ISO-8601
      "name": "vip_earned"
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment