Developer Showcase #7: Joe Rollinson, CEO — Best Worlds

Justin Fink
Klaviyo Developer Blog
8 min readJan 23, 2023
This is a guest post written by Joe Rollinson, CEO at Best Worlds.

Background

Best Worlds is an ecommerce agency and one of the first Klaviyo partners to earn Klaviyo’s Systems Integrator (SI) certification. We have a growing reputation as a leading agency to assist with custom development, for example, if an ERP or POS doesn’t have an existing integration with Klaviyo.

Why did we build with Klaviyo?

As an eCommerce agency, we have many clients that have chosen to use Klaviyo for their marketing communications. Best Worlds had clients asking to connect software to Klaviyo that didn’t have an existing integration with Klaviyo. After further discovery, we were impressed by Klaviyo’s flexible architecture and started recommending optimizations to our other clients. Additionally, we believe Klaviyo is especially strong when it comes to getting data in and out of it, and have been tapped to do numerous Klaviyo projects.

Klaviyo Insights

Wine Direct <> Klaviyo Integration

We work a lot with Klaviyo’s ‘events’ (individual actions performed by a profile) and this is a powerful paradigm within the Klaviyo architecture. For example, when wineries have someone book a visit to their tasting room, that event doesn’t pass through their website. But we can identify that event through their backend, Wine Direct POS system, and get that event over to Klaviyo. Now, the winery can set up automations and send follow-ups if an individual purchased wine v. if that individual left without buying anything. For many wineries, this is the very top of their business funnel, but it’s offline, so capturing the relationship and following up on auto-pilot means taking action on thousands of prospects that were not getting any one-on-one communication prior to the integration.

Today, Best World’s Wine Direct integration also synchronizes contacts, orders, and lists with Wine Direct using Klaviyo’s APIs. You can read more about the integration here.

Supporting Advanced Replenishment

For a high-volume tea retailer, we augmented the order data with an additional event, a custom field the merchant added to their Shopify account to categorize the overall size of the purchase. While some of the products are sold in bulk offerings (customers wouldn’t expect to need to restock for months), other products could easily be consumed within one month.

To solve this, the merchant classified all of the different SKUs with a “replenishment size” that then corresponded to the timing they wanted to use to follow up, so their replenishment flows were sent at the right interval after purchase.

Below highlights a screenshot of the “Weight and Qty Data” event we send to Klaviyo to be used for replenishment flows:

Maintaining Cart Data in a Profile Property

One of our clients wanted to be able to include an abandoned cart directly inside of any marketing campaign they were sending. This meant Best Worlds had to store the cart in a profile as a custom property given the data in the default ‘Checkout Started’ that Klaviyo sends is not available to campaigns (typically only accessed inside of flows triggered by that event).

To do this, Best Worlds: (1) stored the cart data in JSON in a custom profile property, then (2) used a django template to recurse through the JSON object to retrieve all of the cart items and a link back to the cart if there was an abandoned cart in the profile. Naturally, we had to delete and update this cart object if an order was placed as well as update the contents each time the cart was edited.

To show the value of this capability, our client decided to A/B test campaigns with the abandoned carts embedded directly in the message against campaigns without them. The client saw a 7% increase in revenue per recipient in the version containing the abandoned cart when split test over an entire month.

Using Google Tag Manager (GTM) and DataLayer Output

One of our most interesting custom integrations was with a website that couldn’t give us API access to any of their order or customer data, but could give us access to that data flowing through data layer variables in their Google Tag Manager. To access this data, Best Worlds used javascript to parse the data layer data and post that data to the Klaviyo’s APIs.

We originally used Klaviyo’s Track API to get event data from the data layer within GTM, but now have the capability to use the Events API and/or Client API to pull similar event data.

<script>
console.log("kl loaded");
var order_payload = {}
dataLayer.forEach(function (D) {
if (D.event == "purchase") {

var Items = {
quantity:0,
brands: [],
titles: [],
categories:[]
}

D.ecommerce.purchase.products.forEach(function(P){
Items.quantity += P.quantity;
Items.titles.push(P.title)
Items.brands.push(P.brand)
Items.categories.push(P.category)
})

order_payload = {
token: "______",
event: "Placed Order",
customer_properties: {
$email: D.ecommerce.customer_email,
$phone: D.ecommerce.phone_number || '',
$first_name: D.ecommerce.firstname || '',
$last_name: D.ecommerce.lastname || '',
$city: D.ecommerce.city || '',
$zip: D.ecommerce.zipcode || '',
$state: D.ecommerce.state || '',
$country:D.ecommerce.country || '',
Address: D.ecommerce.address || '',
website_language: D.ecommerce.language,
},
properties: {
$event_id: D.ecommerce.purchase.actionField.id,
$value: D.ecommerce.purchase.actionField.revenue,
"Order ID": D.ecommerce.purchase.actionField.id,
Currency:D.ecommerce.currencyCode,
Language: D.ecommerce.language,
Items: Items.titles,
Quantity:Items.quantity,
Brands: Items.brands,
Store: D.ecommerce.store || ''
},
};
}
});
console.log(order_payload)
var data =
"data=" +
btoa(
JSON.stringify(order_payload)
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
);
fetch("https://a.klaviyo.com/api/track?" + data)
.then(function (data) {
return data.json();
})
.then(function (result) {

})
.catch(function (e) {
console.error("klaviyo error", e);
});
</script>

Moving Offline to Online — Mobile Capture for SMS

Another interesting project was helping a merchant with brick and mortar stores gather consent for SMS marketing from cashiers when customers are paying at the register. This particular merchant had a strong customer base shopping in-store, but had not been able to translate that into a healthy list of contacts that they could stay connected with via SMS or email.

Because their POS offers the ability to have cashiers enter the consent and mobile number at checkout, we will be capturing new opt-ins through the POS API and inserting those into Klaviyo so this merchant can make special offers for in-store customers to make purchases through their ecommerce website.

We can see huge potential in this approach for brick and mortar stores to capture more digital relationships with their customers.

See Klaviyo help article for more details.

Tips, Tricks, and Learnings

To date, Best Worlds has built custom integrations with Salesforce, Netsuite, Wine Direct, RICS Point of Sale, ShopVox Point of Sale, VinoShipper, Active8 POS and others. Additionally, we have also added lots of custom data to the default data Klaviyo is sending through its apps/extensions for Shopify, BigCommerce, and Magento.

Through all of this, one of the most interesting learnings was running our middleware code in the cloud using Amazon Lambda.

With Klaviyo’s new acquisition of Napkin.io, you can use similar functionality to create and deploy serverless cloud functions instantly, all from the browser. Check it out!

Free Serverless Middleware with AWS Lambda

For many of these built integrations, the code has to run on its own schedule to request data from the source and then insert it into Klaviyo. AWS Lambda provides free serverless resources for up to 1 million requests per month and 400,000 GB-seconds of compute time per month. In most cases this is plenty of headroom for the middleware querying the source order and customer data and inserting it into Klaviyo.

We are using the Node.js language to code our application in Lambda and we’ve installed some packages that we use in our code like node-fetch, AWS SDK, etc. We have to be careful with the NPM packages we install because Lambda has a space limit of 250MB on the free package.

To carry out our integrations with Klaviyo, we use complementary services such as DynamoDB, SES (Simple Email Service), EventBridge and Cloud Watch (monitor). The AWS SDK package installed via npm allows us to connect our application with these services. We use the DynamoDB service, a NoSQL database, to keep the synchronization up to date and to keep track of the history of tasks run.

Lastly, to execute our Klaviyo sync on a schedule, we use the AWS EventBridge services where we can create rules to execute AWS Lambda functions on a schedule.

Best Worlds monitor the executions of the Lambda function with AWS Cloud Watch.

Fixing Data Issues After Import

Another place where Klaviyo’s architecture has really saved us is the ability to delete certain events without affecting the contacts associated with those events. We typically start off our custom integrations by bringing in 100 test orders into our own Klaviyo test account (to set up a test account, see here). Then, we have our clients think about the different use cases for flows and segments that they plan to build with this data. Once they’re satisfied that our events have the data from their original data source that they need, we proceed with a historical order import. But, when merchants are bringing over 10 years of past order data, there are cases when events may not be captured by the 100 test orders.

To resolve this, we’ve had to make corrections to the historical order data after we’ve brought it into Klaviyo and the customer helps identify any missing data that wasn’t noticed during the test imports. This has typically been for “Placed Order” events, where we need to delete everything that was brought in previously so we can do a fresh import with updated data.

Klaviyo’s ability to delete JUST certain events has been a lifesaver on many occasions!

Conclusion

We love working with Klaviyo because when we check back with clients six months after we deliver our custom integration, they are typically really happy with the power of Klaviyo to segment and automate without the need for major developer investment. Everything we do is rooted in ROI, and we love how easy it is to make the case for the investment.

Typically with a few more transactions per month, the effort in Klaviyo and the work we have to do to integrate it with a customer’s platform quickly pays for itself. Additionally, with some diligence when creating the automation, it can take on a life of its own in helping drive revenue growth. We’ve seen Klaviyo become a major percentage of our clients’ revenue and in certain cases has really transformed their business.

To learn more…

  1. Check out Best Worlds’ offerings and reach out if interested in working with a leading SI / agency.
  2. Review Klaviyo’s developer portal to start building for 100,000+ Klaviyo customers today!
  3. To learn more about Klaviyo’s new acquisition of Napkin.io, click here to start testing out its new capabilities for free!

--

--

Justin Fink
Klaviyo Developer Blog

I am passionate about the developer community and intersection of business and technology. Currently, I am the Director of Developer Marketing at Klaviyo.