Skip to main content
Solved

Event migration to new API


Forum|alt.badge.img

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

Best answer by Maxbuzz

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

View original
Did this topic or the replies in the thread help you find an answer to your question?

2 replies

Forum|alt.badge.img+31
  • Partner
  • 252 replies
  • Answer
  • April 2, 2024

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


Forum|alt.badge.img
  • Author
  • Contributor I
  • 1 reply
  • April 3, 2024

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"
            }
          }
        }
      }
    }
  }