How to Track Conversions when Using a Custom HTML Form

OptinMonster allows you to use any Email Service Provider or fully customize your campaign forms using our Custom HTML Campaign Form integration option.

In this article, you’ll learn how to set cookies and track conversions when using our custom HTML integration option.

Before You Start

Here are some things to know before you begin:

  • This article assumes you’re already familiar with how the Custom HTML Integration works.
  • Cookies control how often your campaign can re-appear to a visitor after they’ve closed or converted through it. Learn more about cookies here.
  • This article involves adding a class to your form’s submit button. A class is a way of naming an element so it can be easily identified.

Track Conversion & Set Cookies

There is a special class that you can use to notify OptinMonster that a conversion has happened and set cookies if they’ve been configured for your campaign.

Add the class om-trigger-conversion to your custom HTML form’s submit button. For example:




<form method="POST" src="http://www.example.com/form.php">
  <input type="text" placeholder="First Name" />
  <input type="email" placeholder="Email Address" />
  <input type="submit" class="om-trigger-conversion" value="Submit Now!" />
</form>



This lets us know that a conversion has taken place when the visitor selects the submit button in your custom HTML form, and also sets a cookie if you’ve specified a Cookie Duration value for your campaign.

Track Conversion Only

If you’d prefer to track conversions only, but not set any cookies, you can use the class om-trigger-alt-converion instead.

For example:

<a href='https://optinmonster.com' class='om-trigger-alt-conversion'>Check out OptinMonster!</a>

Troubleshooting

My custom form is in an iFrame element, can I still add this class?

At this time it’s not possible to track conversions if your form is within an iFrame element. This is a limitation of technology and not unique to OptinMonster.

If your Email Service Provider has a non-iFrame version of the form embed code you should use that instead and follow this guide to add the required class to track conversions and set cookies.

Why doesn’t my Custom HTML form with Javascript track conversions?

If your custom form is using Javascript on the submit event, then you’ll want to ensure that the last line of the Javascript submit code is:

return true;

EXCEPTION: If you are doing any sort of redirect if the submission is successful on your customized submission Javascript code then there is nothing OptinMonster can do to track the conversion.