Skip to content

Instantly share code, notes, and snippets.

@MoonMoon85
Created August 9, 2018 05:41
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 MoonMoon85/ec4470338b96fc0f6a423506959e491b to your computer and use it in GitHub Desktop.
Save MoonMoon85/ec4470338b96fc0f6a423506959e491b to your computer and use it in GitHub Desktop.
Optimizely - Viewed Page Audience
var viewedPage = false;
var pageviews = optimizely.get("behavior").query({
"version": "0.2",
"sort": [{
"field": ["time"],
"direction": "descending"
}],
"filter": [{
"field": ["type"],
"value": "pageview"
}]
});
pageviews.forEach(function(pageview) {
// Add your Page Name between the single quotes
if (pageview.name == 'your page name here') {
viewedPage = true;
}
});
viewedPage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment