Skip to content

Instantly share code, notes, and snippets.

@tomfuertes
Created April 30, 2015 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomfuertes/59a73d8fe530885b9dc6 to your computer and use it in GitHub Desktop.
Save tomfuertes/59a73d8fe530885b9dc6 to your computer and use it in GitHub Desktop.
performant pdp layout differences
/* _optimizely_evaluate=force */
$(function () {
$('a').each(function () {
var $this = $(this);
var href = $this.attr('href');
if (/TODO_PDP_REGEX/.test(href)) { // TODO - Replace This with PDP Regex
$this.attr('href', href+'?utm_content=different_layout');
}
});
})
/* _optimizely_evaluate=safe */
/* _optimizely_evaluate=force */
if (!/utm_content=different_layout/.test(location.href)) { // only if we haven't already redirected
var _optly={redir:document.createElement("a")};
_optly.redir.href=window.location.pathname+"?utm_content=different_layout";
_optly.cur=window.location.search;
if (_optly.cur) {_optly.redir.search=_optly.redir.search ? _optly.cur + "&" + _optly.redir.search.slice(1) : _optly.cur;}
window.location.replace(_optly.redir.href);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment