Created
October 11, 2013 10:08
-
-
Save vchub/6932435 to your computer and use it in GitHub Desktop.
Revisions
-
vchub revised this gist
Oct 11, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ return splitVal; } </script> // .... // </head> -
vchub created this gist
Oct 11, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ // head> // ... <script type="text/javascript"> /* A/B splitting - Returns either "A" or "B". */ function getABsplit() { var cookieDomain = ".your_domain.ru"; var cookieName = "gr_split_GLOBAL"; var cookieExpire = +new Date()+1000*60 * 60 * 24 * 365; // get cookie var m = (new RegExp(cookieName+"=([^;]*)")).exec(document.cookie); var splitVal = (m == null ? null : unescape(m[1])); if (splitVal == "A" || splitVal == "B") {return splitVal} splitVal = (Math.random() < 0.5) ? "A" : "B"; // set cookie document.cookie = cookieName + "=" + escape(splitVal) + ";expires=" + new Date(cookieExpire).toUTCString()+ ";path=/" + ((cookieDomain != null) ? ";domain=" + cookieDomain : ""); return splitVal; } // </script> // .... // </head> // using gravity set cookie if ($.cookie('gr_split_GLOBAL') != "A") { _gravity.push({ type: 'recommendation', callback: callback_fn, numberLimit: 5, scenarioId: "ITEM_PAGE", currentRegionId: 0, currentItemId: 287265, resultNames: ["itemId"] }); };