How to Add a MonsterLink to a WordPress Menu

Looking for an easy way to add a MonsterLink to your WordPress menu? Now you can with just a few easy steps. Follow this guide to add a MonsterLink to a WordPress menu.

  1. Add Link to WordPress Menu
  2. Add Attribute to Menu Item
  3. Enable MonsterLink Display Rule
  4. Go Live with Campaign

We’ll start by adding a link to the WordPress menu that will become our MonsterLink.

Log into the WordPress admin, then navigate to Appearance > Menus and select the menu you wish to add a MonsterLink to.

Select the Custom Links tab to add a custom link. Enter a hashtag symbol (#) to the URL field, add your own custom Link Text and select the Add to Menu button before saving the changes to your menu.

The first step in adding a MonsterLink to your WordPress menu is adding a new custom link.

Step 2 – Add Attribute to Menu Item

To add the required data-optin-slug attribute to our MonsterLink menu item use the following filter added to your active theme’s functions.php file:

add_filter( 'nav_menu_link_attributes', 'ekf_menu_attribute_add', 10, 3 );
function ekf_menu_attribute_add( $atts, $item, $args )
  // Specify the menu item ID we want to add our attribute to
  $menu_link = 64;

  // Conditionally match the ID and add the attribute and value
  if ($item->ID == $menu_link) {
    $atts['data-optin-slug'] = 'jiqobgwsx9qinkci';
    $atts['class'] .= 'manual-optin-trigger';
  //Return the new attributes
  return $atts;

We need to make two edits to this filter before it will work for our own MonsterLink.

First go ahead and grab the ID of your MonsterLink menu item. An easy way to do this is return to the Menu edit screen and hover over the Remove link for our MonsterLink, at the bottom of the browser window you can see the url preview for this link which also contains the Menu Item ID.

In the screenshot below, you can see where the url contains menu-item=64 and 64 is the ID of our MonsterLink.

You can preview the Menu Item ID by hovering over the Remove link in the Menu edit screen.

Second, you’ll need the slug of the campaign you want to open when the menu item is selected. You can locate this by logging into your OptinMonster Dashboard. If you click on the dots under Actions the slug is shown at the bottom and is labeled Unique ID.


Once you’ve updated the filter with the menu item ID and campaign unique ID slug go ahead and save the changes.

While you’re logged into your OptinMonster Dashboard, open your campaign in the Builder and in the Display Rules panel enable the MonsterLink (On Click) option.

Enable MonsterLink loading for your campaign in the Display Rules panel.

Step 4 – Go Live with Campaign

The final step is ensuring your campaign is Live in the OptinMonster API plugin.

Navigate to the WordPress Admin > OptinMonser > Optins tab view and select the Go Live link for your MonsterLink campaign to enable it on your site.

You can enable your campaign in the OptinMonster API plugin by selecting the Go Live link in the Optins list view.

That’s it! Now you can check out the new MonsterLink in your WordPress Menu in action!


Q: My menu item still isn’t triggering my campaign to appear, why?

A: This will typically be caused by one, or several, of the following issues preventing your campaign from being correctly triggered:

  • Custom Walker Class: your active theme may be using a custom walker class that you’re not aware of. You can check with the theme author to confirm if this is the case, then use the alternative method show in the Troubleshooting step above.
  • Incorrect Menu ID: double check the menu ID you’ve indicated in the filter added to your theme’s functions.php template file. If you add, then remove, then re-add the menu item to your site’s menu it will have a different ID than it did originally so keep that in mind if you make changes to your site’s menu.
  • Campaign’s Output Settings Incorrect: if the campaign’s embed code isn’t being output to the page there is no campaign to be triggered to appear when the menu item is selected. From the WordPress Admin > OptinMonster > Optins tab view select the ‘Edit Output Settings’ link to check the Output Settings. If the menu is loading site-wide there should be no options within the Advanced Settings panel configured.