How to Integrate OptinMonster with Drupal 8

Have a Drupal 8 website you want to add OptinMonster too? We make it simple with our embed codes! This doc will show you how integrate OptinMonster into your Drupal 8 website.

  1. Create and Publish a Campaign
  2. Paste the Embed Code

Step 1 – Create and Publish a Campaign

The first step is to create a campaign and retrieve it’s embed code. See this guide on how to embed your campaigns on your site for a step-by-step walkthrough if you need assistance.

Step 2 – Paste the Embed Code into a Custom Block in Your Drupal Site

Login to the admin of your Drupal site and select the Structure link from the admin menu.

Click on Structure

Next, click Block Layout.

Click Block Layout

Click Custom Block Library.

Click Custom Block Library

Click the blue button Add custom block.

Click Add Custom Block

On the Add Custom Block screen you’ll complete the following steps:

  1. Enter a Block description to easily identify this campaign’s block in Drupal.
  2. Select Full HTML from the text format dropdown.
  3. Select the Source icon in the Body toolbar.

Now you can paste your OptinMonster embed into the body of your custom block.

Please be careful to follow the steps above in order. If you paste the embed code BEFORE changing the Text Format or without choosing Source, the script itself will display on your live site.

Add a title, change the text format, select source and paste your code. Then save your custom block.

After saving, you’ll be returned to the list view of the Custom Block Library.

Click the Block Layout tab to return to the area where you’ll place your block in the footer region.

Once there, locate a Footer region. If your theme has several footer regions, you can choose any of them.

Click the grey button Place Block.

Place the Custom Block in a Footer region

Click the grey Place Block button next to the Custom Block you previously created.

Click the grey Place Block button next to the custom block you previously created.

Configure your custom block by adding a title. Uncheck the box to display the title.

Give the custom block a title, and do not display the title. Click Save.

Save your block.

NOTE: If you’re adding an inline type campaign (After Post / Inline or Sidebar), you’ll add either the HTML Placeholder (if using a Sitewide Embed) or the entire Campaign Specific Embed where you want your campaign to appear on the page.

Looking to increase conversions on your new campaign? Check out our  list of A/B tests to run on your popups to get more email subscribers.


Q: I have questions about how the Embed Code works.

A: If you have any questions, such as:

    • What domain do I enter when creating my campaign?
    • What’s the difference between the Sitewide and Campaign Specific embed codes?
    • I’m using the Sitewide Embed, how do I control where my campaigns load?
    • I’m using the Sitewide Embed, how do I control where on the page my After Post / Inline or Sidebar campaigns appear?
    • Does the embed code have to be pasted before the closing </body> tag?
    • How do Afterpost and Inline Campaigns work with Embed Codes?

All of the questions above are answered on our main Embed Documentation available here.