How to Use Success Triggered Scripts

Do you have a script you would like to run when someone completes a campaign of yours? Would you like to fire an independent tracking pixel from Facebook or Pinterest? Our Success Triggered Scripts make this easy to accomplish.

  1. What Triggers a Success Event?
  2. Add Script Tags
Requirements: This guide presumes you’ve read and understood the Creating Your First Campaign guide and that your campaign is already on your site.

Step 1 – What Triggers a Success Event?

When editing your campaign in the Campaign Builder, you can go to the Success Panel. There you should see a field called Success Triggered Scripts.

Success-Triggered-Scripts

The Success Triggers will run even if you are using Custom HTML or Canvas.

You can ensure the Success Event is fired by having your submit button be an input element that has the om-trigger-conversion class.

More information about the input HTML element can be found here.

To summarize, your HTML which will trigger the success script should look similar to the following:

<input type="submit" class="om-trigger-conversion" value="Click Here!" />

Step 2 – Add Script Tags

All JavaScript / jQuery needs to be wrapped in script tags, no matter where you’re placing your Scripts within OptinMonster. Therefore, if you are using the Success Triggered Scripts then you also need to have it within Script Tags.

<script>
/* Your JavaScript or jQuery code. */
</script>

Congratulations, you’re ready to go with your Success Triggered Scripts. Check out our Testing Guide to confirm everything works as you expect.


Examples

Let’s say you wanted to grab the values that were entered into your Native Integration to use for another purpose.

Did you know? One purpose could be to set up a follow-up campaign (a “MonsterChain”), utilizing Dynamic Text Replacement.

You can grab the code by doing something like the following, which will display the values into the console:

<script>
    console.log('The name is: ' + jQuery('#om-yjujjtod8wruqb2js8sw input.omaha-field-name').val());
    console.log('The email is: ' + jQuery('#om-yjujjtod8wruqb2js8sw input.omaha-field-email').val());
</script>