How to Use WordPress Shortcodes with OptinMonster

OptinMonster allows you to easily use Shortcodes from your WordPress plugins or theme with our templated campaigns. Follow our documentation to learn how to use WordPress Shortcodes with OptinMonster.

  1. Add Your Shortcode
  2. Refresh campaigns in the OptinMonster API Plugin
  3. Go Live
  4. View & Test Your campaign
  5. Making Style Adjustments (optional)
IMPORTANT: In order to use shortcodes in your campaigns you must also use the OptinMonster API WordPress plugin.

Step 1 – Add Your Shortcode

In this demo we’ll add a WPForms shortcode, so we can copy the shortcode for our form after selecting the Embed button in the plugin’s form builder.

Copy Shortcode

Once you’ve copied the shortcode, head over to the campaign builder and navigate to the Integrations panel. Select the Custom HTML option from the Email Provider list and paste the shortcode into the provided field.

Add Shortcode to Custom HTML

Note: The campaign builder will not show you a live preview of the parsed shortcode; no need to worry that the shortcode appears in the preview exactly as you pasted it into the Custom HTML Form Code field.

Save the changes to your campaign before proceeding.

Did you know?: With OptinMonster’s Plugin, you can use our Advanced Targeting Rules to target WordPress Categories, Tags, and more. Learn how our WordPress Plugin and Display Rules work together.

Step 2 – Refresh Campaign in the OptinMonster API Plugin

Before the campaign can display the shortcode it contains, the campaigns list in the OptinMonster API plugin needs to be refreshed. This needs to be done every time you add, edit or remove a shortcode from the campaign.

Navigate to the WordPress Admin > OptinMonster > campaigns tab view and select the Refresh Campaigns button.

Refresh Campaigns

Step 3 – Go Live

Next, in the OptinMonster plugin, select the Go Live link for your campaign to output the embed code across your site.

Go Live

NOTE: The OptinMonster API plugin controls where the embed code is placed throughout your site. For specific page targeting we recommend you use the Display Rules in the campaign builder following our page-level targeting guide.

Step 4 – View & Test Your Campaign

Go ahead and load the front-end of your site where you’ve specified the campaign should load to ensure the shortcode is being correctly parsed.

Preview Campaign

Here the shortcode is being correctly parsed, but there are a few more things we can do to make our form look more enticing.

Step 5 – Make Style Adjustments (optional)

As with any campaign using the Custom HTML integration option, you may wish to add CSS to control the appearance of the campaign’s contents.

You can easily add CSS to your campaign in the Campaign panel’s Custom CSS field.

Add Custom CSS

Save any changes before returning to the front-end of your site to view the updated campaign.

Styled Campaign

That’s it, you’ve successfully added a shortcode to your campaign!

Want to track conversions on your custom campaign form? See our guide on how to track conversions with a Custom HTML form!


Q: What if I’m manually adding the embed code to my site? What if I’m using Google Tag Manager to display my campaigns on my site?

A: If you’re manually adding the embed code or using Google Tag Manager instead of the OptinMonster API plugin for WordPress the shortcodes will not be parsed in your campaigns. If you want to use shortcodes in your campaigns you’ll need to use the OptinMonster API plugin to control where the campaigns appear on your site instead.

Q: Do I need to use both the WordPress Plugin and the Display Rules?

A: Learn how our WordPress Plugin and Display Rules work together.