OptinMonster Documentation

Documentation, Reference Materials, and Tutorials for OptinMonster

Home

Docs

How to Use OptinMonster’s Custom Javascript Tool

How to Use OptinMonster’s Custom Javascript Tool

OptinMonster makes it easy to customize your campaigns using Javascript.

In this article, you’ll learn how to use OptinMonster’s custom Javascript tool.

Before You Start

Here are some things to know before you begin:

  • The custom Javascript tool can be used to:
    • Load custom fonts
    • Set custom cookies
    • Load additional resources, like custom animation libraries
    • Include language translation based on location
    • Add support for 3rd-party tools
    • Load custom Google Analytics events for more in-depth tracking
    • … and much more
  • Code added using our custom Javascript tool only run when the campaign HTML is on the page, so you don’t need to worry about async loading.

Custom Javascript Tool

To use OptinMonster’s custom Javascript tool, follow these steps:

  1. In the Design view of the campaign builder, select the Settings icon.
  2. Next, select the Advanced tab in the sidebar and expand the Custom JavaScript option.
  3. Enter the Javascript you want to run when the campaign is loaded on your site into the provided field.
  4. When you’re finished, click Save.

Troubleshooting

Do I need to wrap my code in <script> tags?

Yes, you must wrap all Javascript in valid <script> tags.

Using the Template Namespace

One important feature of your OptinMonster campaign is the Template Namespace. This can be found in the Advanced tab’s Display Settings option.

You can customize the campaign namespace to use in CSS and Javascript targeting.

The HTML namespace prefix is used throughout your campaign template for classes and IDs and can be useful for getting around things like ad blockers.

You can use the Template Namespace in your custom Javascript with the placeholder {{ns}}.

Just like the {{id}} placeholder, the {{ns}} placeholder will automatically be updated to use your campaign’s namespace when the Javascript is output in the campaign on your site.

Be advised that changing the Namespace setting will force a page refresh on save.


Still stuck?

How can we help?

Last updated on


Start Getting More
Leads & Sales Today
with OptinMonster!

Create and launch smart capture forms today in minutes. What are you waiting for?

Create and launch smart capture forms
today in minutes. What are you waiting for?

OptinMonster has transformed our business. Before integrating their optins, our clients saw a 2% conversion rate from web traffic, which is slightly above the standard for their industry. With the integration of OptinMonster’s lightbox popup, exit-intent technology, split testing, and other tools, our client’s conversion rates soared by an unprecedented 500%. They attracted substantially more customers while spending less on digital advertising. Their success propelled them to the top of their markets, outperforming national chains and other medical spas with much bigger marketing budgets. Our client’s success in their market has distinguished us in our own. We are now one of the most sought-after marketing firms in the industry of aesthetic medicine. We know that the integration of OptinMonster, more than any other tool or marketing strategy, has supported this growth and achievement.

chris zelig medstar media

Chris Zelig

Partner, Medstar Media

OptinMonster has been a game-changer for us. From driving donations to collecting new leads, there is nothing that this simple tool has failed to accomplish. Our lead collection rate has jumped by over 1,000%.

joe lowe american bird conservancy

Joe Lowe

Director of Digital Communications, American Bird Conservancy

Through OptinMonster’s exit-intent popups, we have more than doubled our sales conversion rate. Best of all is the compound effect of using OptinMonster over a long period of time—more conversions mean more customers, which means more word of mouth.

mitch smith, managing director, shockbyte

Mitch Smith

Managing Director, Shockbyte.com