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 that signs up through a Klaviyo form on your website. It's then up to you to 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 email_subscribe). The selector for that form is then #email_subscribe
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.
<script>
(function() {
  var attachLangToKlaviyo = function(lang) {
    KlaviyoSubscribe.attachToForms('#email_subscribe', {
      hide_form_on_success: true,
      extra_properties: {
        $lang: lang
      }
    })  
  }
  attachLangToKlaviyo(Weglot.getCurrentLang())
  Weglot.on('languageChanged', attachLangToKlaviyo)
})()
</script>
This code will get the language used by the visitor when he submits the Klaviyo form and will send the language tag to your Klaviyo plugin.
It means that when a visitor will submit your newsletter Klaviyo form, this visitor should be created into your Klaviyo plugin with a lang tag related to the lang used on the website when he submitted the form.
Note that the tag could only be added to the new registered customers and can not be done to customers that have signed up before the integration of the script.

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:
<script>
(function() {
  var identifyLanguageToKlaviyo = function(lang) {
    var _learnq = window._learnq || [];
    _learnq.push(['identify', {
      $lang: lang
    }]);
  }
  identifyLanguageToKlaviyo(Weglot.getCurrentLang())
  Weglot.on('languageChanged', identifyLanguageToKlaviyo)
})()
</script>
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