Reputation: 132
I have this kind of cookie in code on page. I would like to get language out of it.
I mean how could I this function return in this example "en" in GTM variable:
function() {return ...}
Code in page looks like:
<script type="text/javascript" id="wtml-cookie-js-extra">
var wtml_cookies = {"wp-wtml_current_language":{"value":"en","expires":1,"path":"\/"}};
var wtml_cookies = {"wp-wtml_current_language":{"value":"en","expires":1,"path":"\/"}};</script>
Upvotes: 0
Views: 885
Reputation: 475
Global variables like that are accessible in the window
object. This code should do it:
function() {
return window.wtml_cookies["wp-wtml_current_language"]["value"];
}
Upvotes: 1