Both APIs are optimized for low latency and high numbers of requests, so they do not adhere to the same REST principles our other APIs use. For more information, review Klaviyo's REST API references.
If you're looking to integrate an ecommerce platform not currently supported by one of Klaviyo’s pre-built integrations or partner integrations, or you’ve built your own custom cart solution, check out our guide Integrate a platform without a pre-built Klaviyo integration.
Responses from requests made to the Track or Identify API will return either
|Success; your data was received and is queued for processing|
|Failure; your data did not decode to valid JSON and was not queued for processing|
We recommend logging any requests that result in a
0response in case you need to verify the structure of the data being sent and resend it later.
API requests are processed asynchronously, typically in less than a second, so when a request returns, there might be a slight delay before data appears inside Klaviyo. In certain cases, such as pixel tracking, it may be better to return a blank pixel rather than a success or failure message. In those cases, you can always return a blank pixel by adding a GET parameter
i=1 to your request.
To get onsite tracking up and running, you’ll need to add the code snippet below to your main store template. Place the code snippet either with any other analytics scripts you use or right before the closing
</body> tag. Replace the “Public API Key” text with your public API key. To find your public API key, navigate to Account > Settings > API Keys. Your public key is six characters long.
This script runs asynchronously and can be added to your site without affecting performance. For more information, see our article on Klaviyo.js and site speed reports. The script is also cached in a user’s browser, so they won’t need to download it every time they switch pages.
This snippet automatically adds the
_learnq object that can then be leveraged by any additional
track snippets you may want to add on the front-end.
The Identify method - which allows you to identify and set properties on an individual - allows you to identify any individual by including either their email address (using the
We highly recommend that you consistently identify all individuals using their email address (
If you choose to use a unique identifier via the
$id key, you will be responsible for identity management within your Klaviyo account. You must ensure every call you make maps the correct
$id to the associated
$id value will cause Klaviyo to create profiles without an associated
As of April 2022, external id ($id) property has a limit of 64 characters. Any characters over the limit will be truncated.
$idkey should never be used to track profiles anonymously, as this has a high potential of creating multiple profiles for individuals in your account if not set up thoughtfully. Only use
$idif a given person has a known
Updated about 1 month ago