Skip to content

Instantly share code, notes, and snippets.

@jtsternberg
Last active October 28, 2020 01:16
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 jtsternberg/f24338ec0d4bbbb507c53b6c91bd1a77 to your computer and use it in GitHub Desktop.
Save jtsternberg/f24338ec0d4bbbb507c53b6c91bd1a77 to your computer and use it in GitHub Desktop.
Runs after the campaign rule-check runs. Can be used to prevent the showing of a campaign even if rules pass.
document.addEventListener('om.DisplayRules.afterRun', function(event) {
var DisplayRules = event.detail.DisplayRules;
var Campaign = event.detail.Campaign;
if ( 'YOUR-CAMPAIGN-ID' === Campaign.id && DisplayRules.show ) {
if ( 'pepperoni' !== window.pizza ) {
// Only allow rules to pass if pizza variable exists
// and it's value is 'pepperoni'.
DisplayRules.show = false;
}
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment