Shopify
Some code around Shopify
Shopify integration is using Javascript integration. There, you will find:
For information, the Javascript initialization snippet is on your Shopify theme, in the
snippets/weglot_switcher.liquid
file.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>
- 1.
- 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>
Last modified 2yr ago