Skip to content

Instantly share code, notes, and snippets.

@mmoravec
Created October 26, 2016 21:45
Show Gist options
  • Save mmoravec/f73d4a9abdfd36bdc7ce1aac0bf42039 to your computer and use it in GitHub Desktop.
Save mmoravec/f73d4a9abdfd36bdc7ce1aac0bf42039 to your computer and use it in GitHub Desktop.
window['optimizely'] = window['optimizely'] || [];
if (window.jQuery("meta[name='section']").length > 0) {
window['optimizely'].push({
type: "page",
pageName: "section_page",
tags: {
category: window.jQuery("meta[name='section']").attr('content'),
type: window.jQuery("meta[property='og:type']").attr('content') === 'website' ? 'section_front' : window.jQuery("meta[property='og:type']").attr('content'),
title: window.jQuery("meta[property='og:title']").attr('content')
}
});
}
// Newsletter timing control (wait 15 seconds before firing newsletter activation calls)
var optlyNewsletterTimeout = setTimeout(function() {
window['optimizely'] = window['optimizely'] || [];
window['optimizely'].push({
type: "page",
pageName: "newsletter"
});
// Check whether we are on an article page and NOT on edition.cnn.com
// if (window.jQuery("meta[property='og:type']").attr('content') === "article" && !window.location.href.match('edition\.cnn\.com')) {
// if (window.jQuery("meta[name='section']").attr('content') !== "politics") {
// If on politics, push Five Things
// console.log("[Optly] activating five things");
// } else if (window.jQuery("meta[name='section']").attr('content') === "politics") { // If not on politics, push Nightcap
//classic Optimizely nightcap desktop
// console.log("[Optly] activating nightcap");
// }
// }
}, 15000);
window.optimizely.push({
type: "addListener",
filter: {
type: "lifecycle",
name: "viewActivated"
},
handler: function(data) {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment