Marketing Automation for Your App
We all know knowledge is power. When our ecommerce development team is working on a custom app project for clients, one common request is to integrate with marketing services. Most apps collect valuable customer data and businesses need to utilize this information. Everything from updating customers about new features, providing notifications and analyzing metrics is actionable data that is critical to a company. So how can we integrate this power into a mobile app or service? Our API integration team uses the Klaviyo API to provide background services that synchronize data with any service seamlessly. Let's review how our team does it.
How to Use the Klaviyo API
When it's time to develop programmatic access to Klaviyo, you need to access their API. Klaviyo provides a robust REST API to manage objects and query data within your Klaviyo account. In order to utilize the API, you must first obtain a Private API Key to authenticate your calls. The API Key is obtained directly from within your account. Log into your account and navigate to the Account section. From there you will click on Settings and API Keys. You should see a screen similar to the one below:
Using the "Create Private API Key" button you can generate a new key to use for authenticated requests. If your application has different marketing requirements, it may be a good idea to create multiple API Keys to separate your requests and provide an additional level of security. You will use these values in every API request in your app or service via a query parameter. Using a standard NVP model, we use api_key as the name and the generated key as the value. For example, your request URL may look somthing like this:
Remember, your private API Keys provide direct account access and should not be shared publically or be visible in client-side scripts.
Make API Calls to Klaviyo
Once you've generated your API Key, you can start making programmatic calls to your account. Klaviyo provides a comprehensive API Reference guide and Open API spec to the available resources. The API guide outlines all of the available endpoints for access to Lists, Segments, Metrics and more. It all starts with the base API URL. We'll plug this into our ENV and then build calls from there. The base Klavyio API URL is:
The Klaviyo API uses a versioning system to ensure backward compatibility. The API versions are concatenated into the base API endpoints so a versioned URL would look like this:
If you want to utilize the new version of the API, then simply change the version number like this:
Using the developer guide, we can now utilize any of the available endpoints to query data. For example, if we want a listing of all our email lists in Klaviyo, we can perform a direct query to the List endpoint and receive the JSON results. Let's use Postman to demonstrate how this works:
The JSON results provide the list ID and name. So now you can use the list_id to automatically add, view or manage the members in your list via the API. Generate new a new URL with an open variable to replace the ID. For example, if you want to list all the members in the Newsletter list, we create a new request using the Group API and list_id value:
Let's demonstrate this using Postman again:
This same process can be repeated to query Segmets, Profiles, Lists, Templates and more. The API also allows the creation of objects so we can automatically add members via POST commands. The API unlocks full compatibility and access to empower external development and integration.
Integrating Klaviyo With Your Project
Using the power of the Klaviyo API we can plug your service into business-critical marketing automation. If your app or service can capitalizing on marketing, it will pave the way toward long-term channel success. Gain direct access to your target audience, and analysis data for future optimization. Using this type of integration, you can nurture your customers to re-engage and turn them into life long advicates for your brand.
If you're looking for an experienced partner to help with your Klaviyo development or integration, then click the button below to get started.