Expand my Community achievements bar.

Targeting DOM element and cookie

Avatar

Level 3

Hi there,

We are trying to target DOM element and cookie value through targetPageParams() function. Essentially we want to do that for 2 separate experiments. You can see the code below. We can see "trackCookie" coming up under Visitor Profile but "DOMElement" is not coming up. Could you please help us out here

function targetPageParams() {

    if(location.pathname.indexOf("contact") > -1){

        var timer = setInterval(function(){

            if($(".ttt:contains('T12')").length > 0){

                clearInterval(timer);

                return "profile.DOMElement=true"; 

            }

        }, 100);

    }else{

        function readCookie(name) {

            var nameEQ = name + "\x3d";

            var ca = document.cookie.split(";");

            for (var i = 0; i < ca.length; i++) {

                var c = ca[i];

                while (c.charAt(0) == " ") c = c.substring(1, c.length);

                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length)

            }

            return null

        }

        return "profile.trackCookie=" + readCookie("superman");

    }

}

Thanks,

14 Replies