Solved

Event migration to new API

  • 2 April 2024
  • 2 replies
  • 27 views

Badge

We have an event that is not linked to profiles, but rather is transactional, can be sent to any email, even if it is not a profile in the system. Our current  event code is as follows:

 

$event = '{
"token" : "blabla",
"event" : "Send VPA Customer Review",
"customer_properties" : {
"$email" : "'.$send->email.'",
"$first_name" : "'.$send->first_name.'",
"$last_name" : "'.$send->last_name.'"
},
"properties" : {
"reviewUrl" : "'.URL::to('/').'/savereview/'.urlencode(Crypt::encryptString($send->uuid)).'",
"first_name" : "'.$send->first_name.'",
"last_name" : "'.$send->last_name.'",
"products": '.$out_json.'
},
"time" : '.time().'
}';
file_get_contents('https://a.klaviyo.com/api/track?data=' . urlencode(base64_encode($event)));

I need to know how to convert this to the new events API found at https://developers.klaviyo.com/en/reference/create_event

icon

Best answer by Maxbuzz 2 April 2024, 09:12

View original

2 replies

Userlevel 3
Badge +7

Hello @vpaaustralia 

 

You can refer to this documentation on how to migrate your existing API to the newer version.

 

https://developers.klaviyo.com/en/docs/migrate_track_identify_and_subscribe_to_our_new_apis

Badge

For interest sake here is the JSON we needed:

 

{
  "data": {
    "type": "event",
    "attributes": {
      "properties": {
        "reviewURL": "https://www.google.com",
        "first_name" : "Jerry",
        "last_name" : "Palmer",
        "products": [

{
"id":"12345678"
"title":"Breakfast Shake"
"image":"https://cdn.shopify.com/s/files/1/234/29/1/files/breakfast-shake-vpa-australia.jpg?v=1712042642"
}

]
      },
      "metric": {
        "data": {
          "type": "metric",
          "attributes": {
            "name": "Send VPA Customer Review"
          }
        }
      },
      "profile": {
        "data": {
          "type": "profile",
          "attributes": {
            "email": "jgp@gmail.com",
         "first_name": "Jerry",
              "last_name" : "Palmer"
            }
          }
        }
      }
    }
  }


 

Reply