Shopify

Some code around Shopify

Send language data to Klaviyo

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 of different languages.

First, locate the HTML ID of the Klaviyo signup form on your page (Usually email_subscribe). The selector to 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 with the actual selector to 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>

Through Klaviyo's Web Tracking Snippet

  1. Make sure you're already using Klaviyo's Web Tracking Snippet on your website

  2. 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>