Klaviyo - Integration/Setup

Using Weglot and Klaviyo, you have the possibility to send language data to Klaviyo with 2 different methods:

1. Through a Klaviyo signup form

This guide will add an extra property called lang to each user who signs up through a Klaviyo form on your website. You then create segments on Klaviyo to send them emails in different languages.
First, locate the HTML ID of the Klaviyo signup form on your page (Usually #klaviyo-form-numbers ). The selector for that form is then #klaviyo-form-URs6Bv

Include the following snippet in your HTML code. Make sure you include it after both Weglot and KlaviyoSubscribe are included. Make sure you replace #email_subscribe  it with the actual selector in the form.

If you use Weglot with the Shopify App, please also add the Weglot snippet before the Klaviyo script
<script type="text/javascript" src="https://cdn.weglot.com/weglot.min.js"></script>
        api_key: 'YOUR_API_KEY'

Here is the script to link Klaviyo:

 function identifyLanguageToKlaviyo(lang) {
        const klaviyoForm = document.querySelector('form[data-testid="klaviyo-form-URs6Bv"]');
        const langAttribute = document.querySelector('html').getAttribute('lang');
            klaviyo.push(['identify', { 'lang': langAttribute }]);
      }, 7000);
  Weglot.on('languageChanged', identifyLanguageToKlaviyo)
  Weglot.on("switchersReady", identifyLanguageToKlaviyo);

This code will get the language the visitor uses when he submits the Klaviyo form and send the language tag to your Klaviyo plugin.

This means that when a visitor submits your newsletter Klaviyo form, this visitor should be created in your Klaviyo plugin with a lang tag related to the language used on the website when he submitted the form.
Note that the tag can only be added to new registered customers and can not be applied to customers who signed up before the script was integrated.

2. Through klaviyo's Web Tracking Snippet

  • Make sure you're already using Klaviyo Web Tracking Snippet on your website.
  • Include the following code after both klaviyo's Web Tracking code and Weglot's switcher code:
(function() {
  var identifyLanguageToKlaviyo = function(lang) {
    var _learnq = window._learnq || [];
    _learnq.push(['identify', {
      $lang: lang
  Weglot.on('languageChanged', identifyLanguageToKlaviyo)
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us