{"id":82202,"date":"2023-02-09T03:06:39","date_gmt":"2023-02-09T08:06:39","guid":{"rendered":"https:\/\/optinmonster.com\/?post_type=optinmonster_docs&#038;p=82202"},"modified":"2025-07-28T15:23:49","modified_gmt":"2025-07-28T19:23:49","slug":"optinmonster-javascript-events-api","status":"publish","type":"optinmonster_docs","link":"https:\/\/optinmonster.com\/docs\/optinmonster-javascript-events-api\/","title":{"rendered":"OptinMonster JavaScript Events API"},"content":{"rendered":"\n<p>The OptinMonster JavaScript Events API is extremely powerful, providing the tools needed to further extend OptinMonster to suit your specific needs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Before You Start<\/h2>\n\n\n\n<p>Here are some things to know before you begin:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>All Javascript events are asynchronous.<\/li>\n\n\n\n<li>All campaign IDs should use your campaign&#8217;s&nbsp;<strong>Unique ID<\/strong>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"use\">Use<\/h2>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/m5y1g8j5.js\/\"><\/script>\n\n\n\n<p>It\u2019s that simple! You can now run your desired actions within the specified event.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"available\">What\u2019s Available<\/h2>\n\n\n\n<p>The following will give you all information about the campaign, as well as access to public JS methods for the campaign.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/32jqjelo.js\/\"><\/script>\n\n\n\n<p>The <strong>event<\/strong> object passes information about the event and the OptinMonster campaign. You can then access those properties within your function.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"om-initiation-events\">Initializing OptinMonster Events<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Api.init\">om.Api.init<\/h5>\n\n\n\n<p>Runs once per page when the API starts.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/d2z3m8ro.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Main.init\">om.Main.init<\/h5>\n\n\n\n<p>Runs once before campaigns are requested.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/ro8nxgko.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Main.parseCampaigns\">om.Main.parseCampaigns<\/h5>\n\n\n\n<p>Runs once after campaigns are retrieved.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/e5wkmp95.js\/\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"campaign-initiation-events\">Initializing a Campaign Events<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaigns.init\">om.Campaigns.init<\/h5>\n\n\n\n<p>Runs once after the document DOM is ready, when campaigns object is initialized, but before the individual campaigns are initialized.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/wox91r1o.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Types.init\">om.Types.init<\/h5>\n\n\n\n<p>Runs while a campaign is initializing and happens after initializing the campaign type object.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/924wzv6o.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Analytics.init\">om.Analytics.init<\/h5>\n\n\n\n<p>Runs while a campaign is initializing and happens after initializing the Analytics object.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/do1kgxk5.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Sites.init\">om.Sites.init<\/h5>\n\n\n\n<p>Runs while a campaign is initializing and happens after initializing the Sites object, but before the sites are matched against the current campaign.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/qor0693o.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Html.init\">om.Html.init<\/h5>\n\n\n\n<p>Runs while a campaign is initializing and happens after initializing the Html object, and, if applicable, before the campaign holder element is attached to the DOM.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/r2m4gqr2.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Iframes.init\">om.Iframes.init<\/h5>\n\n\n\n<p>Runs while a campaign is initializing and happens after initializing the Iframes handler object.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/m5y1gk45.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Listeners.init\">om.Listeners.init<\/h5>\n\n\n\n<p>Runs while a campaign is initializing and happens after initializing the Listeners object, but before the event listeners are added.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/32jqjp3o.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Lock.init\">om.Lock.init<\/h5>\n\n\n\n<p>Runs while a campaign is initializing and happens after initializing the Lock content-locking handler, but before locking\/unlocking happens.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/323rjvy2.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.SoundEffects.init\">om.SoundEffects.init<\/h5>\n\n\n\n<p>Runs while a campaign is initializing and happens after initializing the SoundEffects object, but before any sound-effects are played.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/d2z3my4o.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Tags.init\">om.Tags.init<\/h5>\n\n\n\n<p>Runs while a campaign is initializing and while initializing the Tags smart-tags handler, but before the tags are replaced.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/ro8nxy3o.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Dtr.init\">om.Dtr.init<\/h5>\n\n\n\n<p>Runs while a campaign is initializing and after initializing the Dtr dynamic-text-replacement handler, and after the <a href=\"https:\/\/optinmonster.com\/docs\/optinmonster-dynamic-text-replacement-api\/\" target=\"_blank\" rel=\"noopener\" title=\"\">global text-replacement functions<\/a> have been called.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/e5wkmrp5.js\/\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"campaign-showing-events\">Showing Events<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.init\">om.Campaign.init<\/h5>\n\n\n\n<p>Runs once when a campaign is initialized.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/rod49yyo.js\/\"><\/script>\n\n\n\n<p>In the following example, we\u2019ll remove the campaign if a video is playing.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/j57ngkz2.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.normalize\">om.Campaign.normalize<\/h5>\n\n\n\n<p>Runs just before any split test elements are normalized.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/g5glme3o.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.canLoad\">om.Campaign.canLoad<\/h5>\n\n\n\n<p>Runs just after a successful check that a campaign is able to load. The campaign is not guaranteed to show.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/r5pzjln2.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.DisplayRules.init\">om.DisplayRules.init<\/h5>\n\n\n\n<p>Runs when the campaign wants to show, just before checking if the display rules are passing.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/joel1rj5.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.DisplayRules.afterRun\">om.DisplayRules.afterRun<\/h5>\n\n\n\n<p>Runs after the campaign rule-check runs. Can be used to prevent the showing of a campaign even if rules pass.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/rovejx95.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Ruleset.init\">om.Ruleset.init<\/h5>\n\n\n\n<p>Runs when the campaign rulesets are being processed just before determining if the Ruleset passes.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/g5gl113o.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Group.init\">om.Group.init<\/h5>\n\n\n\n<p>Runs when the campaign rulesets are being processed just before determining if the Group in a Ruleset passes.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/7oq1nnz2.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Rule.init\">om.Rule.init<\/h5>\n\n\n\n<p>Runs when the campaign rulesets are being processed just before determining if the Rule in a Group in a Ruleset passes.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/rod4vvvo.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.WebFonts.init\">om.WebFonts.init<\/h5>\n\n\n\n<p>Runs when a campaign is being initiated and handles initializing the webfonts object, just before any font-loading\/pre-loading occurs.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/j57nlln2.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Html.images\">om.Html.images<\/h5>\n\n\n\n<p>Runs when a campaign is being initiated and just before any image-loading\/pre-loading occurs.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/e50k11zo.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.startShow\">om.Campaign.startShow<\/h5>\n\n\n\n<p>Happens before beginning the process of showing the campaign. Processes a couple more checks before showing, but has already passed the rules.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/y26lzzd2.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.canShow\">om.Campaign.canShow<\/h5>\n\n\n\n<p>Runs just after a successful check that a campaign can show on the page (e.g. no other campaign is currently visible).<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/qo96zzwo.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.show\">om.Campaign.show<\/h5>\n\n\n\n<p>Runs before om.Campaign.load and before all campaign settings are initialized.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/m5l977m5.js\/\"><\/script>\n\n\n\n<p>In this example, we\u2019re going pause a video playing on the page if a certain campaign is about to show.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/x5nj11ko.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.DisplayRules.actions\">om.DisplayRules.actions<\/h5>\n\n\n\n<p>Runs right before any display rules actions are run for rules that have successfully passed.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/wox9kkyo.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Html.show\">om.Html.show<\/h5>\n\n\n\n<p>Runs right before the campaign form HTML is processed and appended.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/924w66xo.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Html.customVars\">om.Html.customVars<\/h5>\n\n\n\n<p>forRuns while the campaign form HTML is being processed and before the smart-tags are replaced.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/do1kww05.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Html.shortcodes\">om.Html.shortcodes<\/h5>\n\n\n\n<p>Runs while the campaign form HTML is being processed and just before parsing any shortcodes for output on the page.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/qor011qo.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Html.append.before\">om.Html.append.before<\/h5>\n\n\n\n<p>Runs while the campaign form HTML is being processed and just before appending it to the DOM.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/r2m40072.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Html.scripts\">om.Html.scripts<\/h5>\n\n\n\n<p>Runs while the campaign form HTML is being processed and just before processing any scripts inside the HTML and adding them to the head of the page.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/05kd44wo.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Html.inlineScripts\">om.Html.inlineScripts<\/h5>\n\n\n\n<p>Runs while the campaign form HTML is being processed, once the external scripts have finished loading, and just before we inject the inline scripts.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/m5y1ee65.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Html.append.after\">om.Html.append.after<\/h5>\n\n\n\n<p>Runs when the campaign form HTML has been processed and appended to the DOM.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/32jqrreo.js\/\"><\/script>\n\n\n\n<p>In this example, we&#8217;ll log a message when the main campaign container has been attached to the outer DOM.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/323rzz12.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Form.init\">om.Form.init<\/h5>\n\n\n\n<p>Runs when the campaign form HTML has been appended to the DOM and just before initializing the campaign form attributes.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/d2z3ppwo.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.PoweredBy.init\">om.PoweredBy.init<\/h5>\n\n\n\n<p>Runs when the campaign form HTML has been appended to the DOM and just before creating and appending the powered-by link.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/ro8n11ro.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Styles.init\">om.Styles.init<\/h5>\n\n\n\n<p>Runs when the campaign form HTML has been appended to the DOM and just before updating the campaign styles for display and before applying any monster effects.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/e5wk33q5.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Actions.init\">om.Actions.init<\/h5>\n\n\n\n<p>Runs when the campaign form HTML has been appended to the DOM and just before initializing the individual action events that are attached to elements in the campaign.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/r5pzjjn2.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Action.init\">om.Action.init<\/h5>\n\n\n\n<p>Runs when the campaign form HTML has been appended to the DOM and just before initializing an individual action event that is attached to elements in the campaign.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/joel11j5.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Countdown.init\">om.Countdown.init<\/h5>\n\n\n\n<p>Runs when the campaign form HTML has been appended to the DOM and just before updating any countdown elements in the campaign.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/rovejj95.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.load\">om.Campaign.load<\/h5>\n\n\n\n<p>Runs just before the campaign actually becomes visible.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/g5gl1l3o.js\/\"><\/script>\n\n\n\n<p>In this example, we\u2019ll write to the browser\u2019s console a message to confirm the successful loading of our campaign.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/7oq1n1z2.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.afterShow\">om.Campaign.afterShow<\/h5>\n\n\n\n<p>Runs just after a campaign becomes visible.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/rod4v4vo.js\/\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"campaign-closing-events\">Closing Events<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.startClose\">om.Campaign.startClose<\/h5>\n\n\n\n<p>Runs at the start of the close function before we check for any conflicts with actually closing.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/j57nlnn2.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.close\">om.Campaign.close<\/h5>\n\n\n\n<p>Runs at the end of the close function just before the close happens.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/g5gl1lxo.js\/\"><\/script>\n\n\n\n<p>In this example, we\u2019ll redirect users to a specific url when the campaign is closed.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/rod4v40o.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.afterClose\">om.Campaign.afterClose<\/h5>\n\n\n\n<p>Runs just after the close function.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/r2m40wg2.js\/\"><\/script>\n\n\n\n<p>In this example, we\u2019ll play\/resume a video on the page when the campaign closes.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/05kd4w4o.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.cleanup\">om.Campaign.cleanup<\/h5>\n\n\n\n<p>Runs before we set cookies, but after a close.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/m5y1ex15.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\">om.Campaign.afterCleanup<\/h5>\n\n\n\n<p>Runs after we set cookies.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/32jqrwxo.js\/\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"campaign-change-view\">Changing Views Events<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.changeView\">om.Campaign.changeView<\/h5>\n\n\n\n<p>Runs right before any view is changed (e.g. Yes\/No to Optin).<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/323rzx02.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.changeView.done\">om.Campaign.changeView.done<\/h5>\n\n\n\n<p>Runs right after any view is changed.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/d2z3p4no.js\/\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"campaign-optin\">Optin Request Events<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Optin.init\">om.Optin.init<\/h5>\n\n\n\n<p>Runs at the start of a conversion attempting being triggered (e.g. click submit on a form before we check validation)<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/ro8n1p9o.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\">om.Form.validate<\/h5>\n\n\n\n<p>Allows you to run custom validation rules.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/e5wk3l05.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Optin.init.submit\">om.Optin.init.submit<\/h5>\n\n\n\n<p>Runs near the end of a conversion being triggered (e.g. after we check validation)<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/r5pzjge2.js\/\"><\/script>\n\n\n\n<p>In this example, we\u2019ll add a custom redirect url (https:\/\/optinmonster.com\/) if the subscriber uses a non-business email address such as yahoo, gmail, hotmail, etc.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/joel1we5.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Optin.error\">om.Optin.error<\/h5>\n\n\n\n<p>Runs any time there is an error in the Optin conversion, but not during validation (e.g. MailChimp responds with test email not allowed).<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/rovejvl5.js\/\"><\/script>\n\n\n\n<p>In this example, we\u2019ll redirect users to a specific url if there&#8217;s an error.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/g5gl1pjo.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Optin.success\">om.Optin.success<\/h5>\n\n\n\n<p>Runs after a successful conversion.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/7oq1nql2.js\/\"><\/script>\n\n\n\n<p>In this example, we\u2019ll close the campaign after a successful conversion. This could be useful where the redirect url results in a direct file download and the campaign remains visible in the browser.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/rod4vwwo.js\/\"><\/script>\n\n\n\n<p>In this example, we&#8217;ll redirect user to a link in a new tab as well as show the success view on the campaign.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/j57nlmp2.js\/\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"analytics-events\">Analytics Events<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Analytics.track\">om.Analytics.track<\/h5>\n\n\n\n<p>Runs any time we are tracking an impression or conversion.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/e50k193o.js\/\"><\/script>\n\n\n\n<p>In this example, we&#8217;ll log a message to the console to let us know our campaign has successfully tracked an impression or conversion.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/y26lzrk2.js\/\"><\/script>\n\n\n\n<p>And in this example, we&#8217;ll push the campaign name and id into the dataLayer so it can be used for parameters in a GA4 Event Tag using <a href=\"https:\/\/marketingplatform.google.com\/about\/tag-manager\/\" target=\"_blank\" rel=\"noopener nofollow\" title=\"\">Google Tag Manager<\/a>.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/qo96zy1o.js\/\"><\/script>\n\n\n\n<p>If you&#8217;re unfamiliar with Google Tag Manager, consider the following resources to learn more:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.analyticsmania.com\/post\/how-to-track-custom-events-with-google-analytics-4\/\" target=\"_blank\" rel=\"nofollow noopener\">How to Track Custom Events with Google Analytics 4<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/youtu.be\/w8FmGPqeCU0?feature=shared\" target=\"_blank\" rel=\"nofollow noopener\">Where&#8217;s the GA4 Config tag? (video)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.analyticsmania.com\/post\/google-tag-manager-custom-event-trigger\/\" target=\"_blank\" rel=\"nofollow noopener\">Google Tag Manager Custom Event Trigger<\/a><\/li>\n<\/ul>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Analytics.impression\">om.Analytics.impression<\/h5>\n\n\n\n<p>Runs any time we are attempting to track an impression. To actually know when an impression is tracked, you will need to use the <code><strong>om.Analytics.track<\/strong><\/code> event.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/m5l97wl5.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Analytics.conversion\">om.Analytics.conversion<\/h5>\n\n\n\n<p>Runs any time we are attempting to track a conversion. To actually know when a conversion is tracked, you will need to use the <code><strong>om.Analytics.track<\/strong><\/code> event.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/x5nj1wro.js\/\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"element-action-events\">Element Action Events<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Action.redirect\">om.Action.redirect<\/h5>\n\n\n\n<p>Runs before a redirect action happens.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/wox9knjo.js\/\"><\/script>\n\n\n\n<p>In this example, we\u2019ll log a message in the browser\u2019s console when the page is about to redirect to the Success URL.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/924w641o.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Action.view\">om.Action.view<\/h5>\n\n\n\n<p>Runs before a view change happens <strong>based on an action<\/strong>.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/do1kwl95.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Action.close\">om.Action.close<\/h5>\n\n\n\n<p>Runs before a close is supposed to happen <strong>based on an action<\/strong>.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/qor018yo.js\/\"><\/script>\n\n\n\n<p>In this example, we\u2019ll close the campaign on success, then begin a direct file download.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/r2m408g2.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Action.window\">om.Action.window<\/h5>\n\n\n\n<p>Runs before a new window is opened <strong>based on an action<\/strong>.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/05kd484o.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Action.refresh\">om.Action.refresh<\/h5>\n\n\n\n<p>Runs before a campaign closes and the page refreshes <strong>based on an action<\/strong>.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/m5y1e615.js\/\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"misc-events\">Miscellaneous Events<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Campaign.reset\">om.Campaign.reset<\/h5>\n\n\n\n<p>Runs when a manual campaign reset has been called. The API will never call reset itself.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/32jqr8xo.js\/\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"om.Styles.positionPopup\">om.Styles.positionPopup<\/h5>\n\n\n\n<p>Runs any time the campaign is positioned in the window. Runs only for Fullscreen and Lightbox campaigns.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/323rzp02.js\/\"><\/script>\n\n\n\n<p>In this example, we\u2019ll make our Lightbox campaign draggable with the <a href=\"https:\/\/github.com\/jeremyckahn\/dragon\" target=\"_blank\" rel=\"nofollow external noopener noreferrer\">Dragon jQuery plugin<\/a> once it\u2019s been positioned on the page. Be sure to enqueue the required files, including jQuery. We recommend you review the <a href=\"https:\/\/github.com\/jeremyckahn\/dragon\" target=\"_blank\" rel=\"nofollow external noopener noreferrer\">readme<\/a> file for the plugin.<\/p>\n\n\n\n<script src=\"https:\/\/library.wpcode.com\/embedjs\/d2z3p9no.js\/\"><\/script>\n\n\n","protected":false},"excerpt":{"rendered":"<p>The OptinMonster JavaScript Events API is extremely powerful, providing the tools needed to further extend OptinMonster to suit your specific needs. Before You Start Here are some things to know before you begin: Use It\u2019s that simple! You can now run your desired actions within the specified event. What\u2019s Available The following will give you&nbsp;&hellip;<\/p>\n","protected":false},"author":7338,"comment_status":"open","ping_status":"closed","template":"","documentation\/categories":[96],"documentation\/tags":[31487],"class_list":["post-82202","optinmonster_docs","type-optinmonster_docs","status-publish","hentry","categories-extending"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/documentation\/82202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/documentation"}],"about":[{"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/types\/optinmonster_docs"}],"author":[{"embeddable":true,"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/users\/7338"}],"replies":[{"embeddable":true,"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/comments?post=82202"}],"version-history":[{"count":26,"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/documentation\/82202\/revisions"}],"predecessor-version":[{"id":204074,"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/documentation\/82202\/revisions\/204074"}],"wp:attachment":[{"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/media?parent=82202"}],"wp:term":[{"taxonomy":"categories","embeddable":true,"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/documentation\/categories?post=82202"},{"taxonomy":"internal_tags","embeddable":true,"href":"https:\/\/optinmonster.com\/wp-json\/wp\/v2\/documentation\/tags?post=82202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}