Comments (1)
Hey Savraj,
Thanks for reaching out.
In our recent upgrade of our APIs, we split both the track
and identify
endpoints into two client- and server-side equivalents, each.
I am assuming you're using these serverside (but correct me otherwise).
In this case, here is how you would migrate:
pip install klaviyo-api
from klaviyo_api import KlaviyoAPI
klaviyo = KlaviyoAPI("YOUR_API_KEY_HERE")
- track -> create_event:
body = {
"data": {
"type": "event",
"attributes": {
"properties": {},
"metric": {
"data": {
"type": "metric",
"attributes": {
"name": "<string>",
}
}
},
"profile": {
"data": {
"type": "profile",
"attributes": {
"email": "<string>",
"phone_number": "<string>",
"external_id": "<string>",
"anonymous_id": "<string>",
"_kx": "<string>",
"first_name": "<string>",
"last_name": "<string>",
"organization": "<string>",
"title": "<string>",
"image": "<string>",
"location": {
"address1": "<string>",
"address2": "<string>",
"city": "<string>",
"country": "<string>",
"latitude": "<string>",
"longitude": "<string>",
"region": "<string>",
"zip": "<string>",
"timezone": "<string>"
},
"properties": {}
},
"id": "<string>",
"meta": {
"patch_properties": {
"append": {},
"unappend": {},
"unset": "<string>"
}
}
}
},
"time": "<dateTime>",
"value": "<number>",
"unique_id": "<string>"
}
}
}
klaviyo.Events.create_event(body)
in your case, you could substitute in the values you have for event
, email
, event_properties
and customer_properties
into the above. Some reminders:
- separate the
customer_properties
into "custom_properties", which would go inattributes.properties
, from the standard predefined customer properties, that go inattributes
andattributes.location
- if your event_properties uses the deprecated
$value
, make sure to move that toattributes.value
(more broadly, we have moved away from the$<attribute>
) in favor of the new predefined properties, which are optional - include
email
withinattributes
, as presumably, that's the identifier you'll be using. the predefined properties above are optional, with the exception of at least on identifier (email, phone_number, etc), so minimally, your payload could look like this:
body = {
"data": {
"type": "event",
"attributes": {
"properties": event_properties,
"metric": {
"data": {
"type": "metric",
"attributes": {
"name": event_name,
}
}
},
"profile": {
"data": {
"type": "profile",
"attributes": {
"email": email,
"properties": customer_properties
},
}
},
"value": event_properties.get('$value'),
"unique_id": "<string>"
}
}
}
- identify -> create_profile:
This is similar to the create_event call above, just with a simpler payload. As above, feel free to remove any of the optional predefined attributes:
body = {
"data": {
"type": "profile",
"attributes": {
"email": "<string>",
"phone_number": "<string>",
"external_id": "<string>",
"first_name": "<string>",
"last_name": "<string>",
"organization": "<string>",
"title": "<string>",
"image": "<string>",
"location": {
"address1": "<string>",
"address2": "<string>",
"city": "<string>",
"country": "<string>",
"latitude": "<string>",
"longitude": "<string>",
"region": "<string>",
"zip": "<string>",
"timezone": "<string>"
},
"properties": {}
}
}
}
klaviyo.Profiles.create_profile(body)
If you have any other migration related questions, we have some resources on this page.
Though to your point, we definitely need to add some SDK-specific migration resources; I'll add that to our team's near-term roadmap.
Definitely reach out if you run into any further issues.
(also, i see you've been a GitHub user since the year it was founded, very cool)
Cheers,
Jon
from klaviyo-api-python.
Related Issues (20)
- How to use "page[size]" parameter? HOT 1
- how to avoid error when making many calls? HOT 1
- No Page Size in "get_profiles" HOT 1
- Missing positional argument "id" even though it is provided HOT 2
- Rendering templates HOT 1
- Feature request: Bulk setting/unsetting of user properties HOT 4
- fields[profile] parameter not working HOT 2
- permissions issue with getting lists + campaign audience type (List\Segment) HOT 1
- klaviyo.Templates.get_template return error 500 HOT 3
- Klaviyo API hangs once every 10-20 requests HOT 4
- _from_openapi_data() missing 1 required positional argument: 'name' on create event HOT 2
- _from_openapi_data() missing 1 required positional argument: 'name' on create event HOT 1
- bug in profile unset property functionality HOT 2
- 400 HTTP errors with get_events() per specific metric ids HOT 4
- Pydantic v2 compatibility HOT 10
- Get Profiles: Phone Numbers Return In Wrong Format HOT 4
- Events.create_event doesn't seem to send the value_currency parameter HOT 4
- Klaviyo profile unable to subscribe: due to HTTPSConnectionPool HOT 2
- "Invalid cursor provided" Error for "get_events()" HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from klaviyo-api-python.