Skip to main content
Contributor I
April 2, 2024
Solved

Event migration to new API

  • April 2, 2024
  • 2 replies
  • 127 views

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

    This topic has been closed for replies.
    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

    2 replies

    MaxbuzzAnswer
    Partner
    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

    https://theforms.pro
    Contributor I
    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"
                }
              }
            }
          }
        }
      }