How to fire events on button clicks with OptinMonster

Recently I was asked if we could add a LinkedIn tracking event to a form on a
marketing website. Upon closer inspection of the form, turns out, it wasn’t
something we had direct control over, and was embedded via OptinMonster.

Having worked on similar lead generation software in the past, I assumed there was probably a way to inject the code snippet. What I wasn’t sure of, is where the heck that lived within OptinMonster. I also wasn’t sure what they would have ended up calling it, since everybody has their own little way to describe stuff these days.

Turns out, it wasn’t too buried, and the naming wasn’t too terrible. Here’s
the steps to be able to add code to when a button is clicked in OptinMonster:

  1. Find the campaign you’d like to add the code to
  2. Click the Edit Campaign button
  3. Click the button you’d like to add the code to
  4. In the left-hand editor, click Click to Edit Button Success Scripts
  5. Drop the code you’d like to fire on click in between the <script> tags
  6. Click the Save button at the top of the page

Not much too it, and aside from calling it “Success Scripts” instead of
something like “Events”, it wasn’t too hard to find.

What I’m not entirely sure of, is whether or not the “success script” fires if
there an error with the form’s input. If it does happen to fire all of the time,
even on error, it would probably be better to edit the success page that is
presented to the user after a successful submission.

Josh Sherman - The Man, The Myth, The Avatar

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.

If you found this article helpful, please consider buying me a coffee.