Hi @Dasost,
Thanks for the follow-up.
This is due to some security changes we recently put into place. Previously, our email-to-website tracking included a base64 encoded parameter with email and public api key included in it. This was called the _ke
parameter. We have since switched to using an exchange id, or _kx
parameter on these urls, which is a hashed user id that only Klaviyo can decode which is far more secure than the previous method. What this means in practice is that _learnq.identify().$email
will no longer work since we do not expose a raw email address to the cookie. Instead, however, we could do something similar to the code given above, but append the exchange id value to each link on one subdomain that then directs to the other.
To retrieve the exchange_id you can either decode the klaviyo cookie and retrieve it, or you can use a method we expose in our frontend library called _learnq.push(["_getIdentifiers"])
. This should return (possibly amongst some other things), a key value pair in an object with $exchange_id
so long as the user is cookied. From the above script provided, we'd just want to edit it to include using the _kx
parameter, rather than the _ke
parameter, and use _learnq.push(["_getIdentifiers"]).$exchange_id
instead of _learnq.identify().$email
while also removing the encoding. I have yet to test this out myself, but I believe the following should take care of the issues you're seeing:
<script>
setTimeout(function(){
if (typeof _learnq !== 'undefined'){
var kl_account = _learnq.account();
var exchange_id = _learnq.push(["_getIdentifiers"]).$exchange_id;
if (exchange_id){
$(document).find('a').each(function(){
if( typeof $(this) !== 'undefined' && typeof $(this).attr('href') !== 'undefined' &&
$(this).attr('href').indexOf('store.') != -1){
var _href = $(this).attr('href');
var param_connector = _href.indexOf('?') == -1 ? '?' : '&'
$(this).attr('href', _href + param_connector + '_kx=' + exchange_id)
}
});
}
}
}, 1200);
</script>
Thanks for being a member of our community.