Skip to main content

Create more targeted onsite experiences with the new Klaviyo JS object

Profile photo of author Jon Palmer
Jon Palmer
3 min read
Klaviyo news
August 30, 2022
Set as Preferred Source

Control onsite timing with JS

Generated by Klaviyo AI

The post explains how Klaviyo’s new JavaScript object adds callbacks and promises to give brands visibility into when Klaviyo actions complete. Readers learn how this enables more precise control over onsite experiences like sign-up forms and how to start using the new object.

  • New JS object: Klaviyo has introduced a JavaScript object that maintains existing functionality while adding support for callbacks and promises.
  • Visibility into actions: Callbacks and promises notify when Klaviyo has completed actions like identifying visitors or updating profile fields.
  • Targeted onsite experiences: Brands can time onsite experiences—such as showing forms or redirecting to thank you pages—based on completed Klaviyo actions.
  • Custom form triggers: The new object supports custom sign-up form triggers, including launching pop-ups when shoppers click specific buttons or links.
  • Implementation options: New customers receive the object automatically, while existing brands can update their Klaviyo code snippet if they want these capabilities.

Klaviyo has released a new JavaScript (JS) object that supports callbacks and promises, giving brands that leverage our APIs more visibility into when updates have been made to Klaviyo’s system. This gives you more control over the timing of customer-facing onsite experiences, such as the triggering of a sign-up form.

The challenge

Callbacks or Promises-JS Object

All brands that track shoppers’ activity on their website and pass that data to Klaviyo have installed a JS object — either through the integration between their ecommerce platform and Klaviyo, or by manually adding a code snippet to their site. For the last ten years, the JS object that has tracked shopper activity and triggered sign-up forms is _learnq.While most brands are able to accomplish all of their use cases for triggering onsite experiences with _learnq and the the setting available in Klaviyo’s form builder, there are some brands with development resources that want to go deeper.

Where _learnq has fallen short for those brands is that it does not notify you when Klaviyo completes an action. So if you wanted to, for example, wait to show a form on your website until Klaviyo lets you know that we have identified a shopper, or wait to redirect a shopper until you know Klaviyo has updated their profile with their birthday or first name, you didn’t have that flexibility. But through the use of callbacks or promises, brands can trigger onsite experiences based on notifications from Klaviyo APIs, making these more customized marketing strategies possible.

The solution

New JavaScript Object

While _learnq has served brands that use Klaviyo well for a long time, we are excited to announce that a new JS object is now available that supports all the same functionality as its predecessor but also supports callbacks and promises. In addition, this new JS object also supports custom sign up form triggers, so you can launch a pop-up as a result of a shopper clicking a button or a link on your website.

All new Klaviyo customers will get the new JS object automatically during onboarding, and brands that want to take advantage of this new functionality can update the Klaviyo code snippet on your site. If you don’t care about callbacks or promises, then no action is required. Klaviyo will continue to support the original _learnq JS object.

Getting started

If you want to take advantage of this new functionality, and you’re ready to get started, replace the existing Klaviyo code on your website with the new JS object. You will then be able to utilize callbacks to trigger events — such as showing a pop-up or redirecting shoppers to a thank you page — when Klaviyo actions such as identifying or tracking site visitors have been completed.

Check out the guide on how to update the Klaviyo JS object on your website.

Jon Palmer
Jon Palmer

Related content

Klaviyo news
Sep 10, 2026
10 takeaways from K:BOS 2026
Klaviyo went headless, AI search orders jumped 13x, and community beat discounts again. See all 10 takeaways from K:BOS 2026 and what they mean for 2027.
Klaviyo news
Sep 9, 2026
What K:BOS means for our partners
Klaviyo's K:Partners Awards, held at K:BOS 2026, recognize 24 partners for sharper strategy, faster execution, and lasting client relationships.
Klaviyo news
Sep 9, 2026
4 Updates Powering Klaviyo's Autonomous B2C CRM
Klaviyo unveiled the Personalization, smarter AI agents, and Klaviyo Headless. See the autonomous B2C CRM in action at K:BOS 2026.