Hi there,
I’m trying to build a tag that will update a custom property with a url parameter.
The url parameter is locale=XX where XX is the value to use as custom property.
Here is the code… I'm not a developer so I'm really not sure if this code is developed as desired... what do you think ?
<script>
var _learnq = _learnq || [];
// Define var locale from url parameter
var str = document.location.href;
var url = new URL(str);
var search_params = new URLSearchParams(url.search);
if(search_params.has('locale')) {
var language = search_params.get('locale');
}
// Identifying a person and tracking special Klaviyo properties.
_learnq.push(['identify', {
'$email' : '',
'language' : language
}]);
</script>
Thanks a lot for the help !