Mautic WordPress integration: step-by-step setup guide
Step-by-step Mautic WordPress integration: tracking code, Mautic forms on your pages, behavior segments and automated campaigns, plus fixes for common issues.

A Mautic WordPress integration lets your site track every visitor, capture leads through forms, segment them by behavior and trigger personalized campaigns, without paying for a marketing automation tool. WordPress brings in the traffic and Mautic handles the follow-up, so the visitors you already get start turning into leads on their own, at no license cost.
This guide sets up visitor tracking first, then lead capture forms, behavioral segments and automated campaigns, and ends with the problems people hit most often.
What a Mautic WordPress integration needs
- Mautic installed: version 5.0 or later. If you do not have it yet, follow how to install Mautic.
- WordPress: version 6.0 or later (any recent version works).
- Your own domain for both Mautic and WordPress. The integration does not work on localhost.
- SSL/HTTPS: required for visitor tracking.
- Admin access on both platforms.
Method 1: the tracking code (recommended)
Step 1: get the tracking code from Mautic
The Mautic tracking code follows visitors automatically, and every other part of the Mautic WordPress setup builds on it.
- Log in to your Mautic instance. The examples below use
https://your-mautic.example.comas the address; replace it with your own domain. - Go to Settings (the gear icon, top right) > Configuration > Tracking Settings.
- Mautic embeds tracking on its own pages automatically. The manual snippet, for pasting into another site, looks like this:
<script>
(function(w,d,t,u,n,a,m){w['MauticTrackingObject']=n;
w[n]=w[n]||function(){(w[n].q=w[n].q||[]).push(arguments)},a=d.createElement(t),
m=d.getElementsByTagName(t)[0];a.async=1;a.src=u;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://your-mautic.example.com/mtc.js','mt');
mt('send', 'pageview');
</script>Step 2: add the tracking code to WordPress
You can do it in three ways.
Option A: a plugin (easiest)
- Install the Mautic or Mautic Form plugin (free on WordPress.org).
- Activate the plugin.
- Go to Settings > Mautic in the WordPress admin.
- Paste your Mautic URL, for example
https://your-mautic.example.com. - Click Save. Tracking starts right away.
Option B: functions.php
Add this to wp-content/themes/your-theme/functions.php, where your-theme stands for your theme's folder:
add_action('wp_footer', function() {
echo <<<'EOT'
<script>
(function(w,d,t,u,n,a,m){w['MauticTrackingObject']=n;
w[n]=w[n]||function(){(w[n].q=w[n].q||[]).push(arguments)},a=d.createElement(t),
m=d.getElementsByTagName(t)[0];a.async=1;a.src=u;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://your-mautic.example.com/mtc.js','mt');
mt('send', 'pageview');
</script>
EOT;
});Option C: a header and footer plugin
The "Header and Footer Scripts" plugin adds the tracking code without touching theme files:
- Install "Header and Footer Scripts".
- Go to Settings > Header and Footer Scripts.
- Paste the tracking code into the "Footer" section.
- Save.
Step 3: check that tracking works
Open your WordPress site in a private or incognito window, so your own session does not get in the way, and visit any page. Then:
- In Mautic, go to Contacts.
- Look for a new anonymous contact (the visitor).
- Click it to see the pages it visited.
Once that anonymous contact shows its page views, the Mautic WordPress tracking is working.
Mautic identifies visitors by cookie. When the same visitor comes back, Mautic recognizes them, and when they fill in a form, Mautic turns the anonymous record into a named contact.
Method 2: Mautic forms on WordPress
On a WordPress site, Mautic forms have a few advantages over WPForms or Gravity Forms. They sync leads to Mautic directly and can trigger campaigns on submit, with no Zapier or n8n in between. The submission also lands in the contact's history, where it counts toward lead scoring. Building forms in more depth is covered in Mautic forms.
Step 1: create the form in Mautic
- Go to Forms > New.
- Give it a name, such as "WordPress contact".
- Drag in the fields: Name, Email, Phone, Company.
- Set what happens on submit, for example sending an email.
- Click Save & Close.
Step 2: copy the form ID
When you edit the form in the Mautic dashboard, the URL looks like this:
https://your-mautic.example.com/s/forms/view/5The last number is the form ID, 5 in this case. The public URL of the form, the one used for embedding, is https://your-mautic.example.com/form/5.
Step 3: add the form to WordPress
Option A: shortcode (easiest)
Create a page or post in WordPress and add this in the editor, replacing 5 with your form ID:
[mautic type="form" id="5"]Option B: iframe (if the shortcode does not work)
Use the public form URL (/form/ID), not the edit URL:
<iframe src="https://your-mautic.example.com/form/5"
width="100%" height="500px"
frameborder="0" scrolling="auto">
</iframe>Step 4: test a submission
- Open the WordPress page that has the form.
- Fill it in with test data, such as "Jane Doe" and "jane@example.com".
- Submit it.
- In Mautic, go to Contacts. Jane Doe should be there as a new contact.
Method 3: behavioral segments from WordPress traffic
Segments group contacts by what they do on your site. A few signals the Mautic WordPress tracking gives you:
- A visit to the pricing page usually means the person is close to a decision.
- Five or more pages visited shows strong interest.
- A filled-in form makes them a qualified lead.
You can then send different emails to each group. Filters and segment strategy get their own guide in Mautic segments.
A segment by behavior
- Go to Segments > New.
- Name it "Qualified lead".
- Add a filter for pages visited, greater than or equal to 5.
- Add a second filter, joined with AND, for form submitted.
- Save.
From then on, Mautic puts every contact who visited 5 or more pages and submitted a form into this segment.
A segment for a specific page
- Go to Segments > New.
- Name it "Visited pricing page".
- Add a page filter with the value
/pricing(or the relative URL of your page). - Save.
Another segment worth having is "Cold visitors": people who visited the site but have not filled in a form in 14 days. Point a retargeting campaign at them.
Method 4: automated campaigns from WordPress behavior
Scenario: a lead magnet with automatic follow-up
A visitor lands on your WordPress site and sees a form offering a free guide in exchange for an email address. Once they fill it in, Mautic:
- Creates the contact.
- Adds it to a "Lead generated" segment.
- Sends the email with the guide right away.
- Starts a sequence of 5 emails, one every 3 days.
- Moves the contact to an "MQL" (Marketing Qualified Lead) segment if they visit the pricing page.
Build the campaign in Mautic
- Go to Campaigns > New.
- Name it "Lead magnet: free guide".
- Click Launch Campaign to open the builder.
- Add a contact source and select the form you placed on WordPress.
- Connect it to a Send Email action with the "Welcome: here is your guide" email, sent immediately.
- After that email, add a wait of 3 days.
- Send email #2, "How to use the guide".
- Repeat until the sequence has 5 emails.
- Click Save & Publish.
Advanced settings
Syncing WordPress members
If you run BuddyPress or a membership plugin on WordPress, you can sync it with Mautic:
- Install "Mautic Webhook" or use n8n in between.
- When a user registers on WordPress, fire a webhook to Mautic.
- Mautic creates or updates the contact with an
is_memberfield set to true. - Send different emails to members and non-members.
Tracking PDF downloads
If you offer ebooks for download on WordPress, put the download on a page that has Mautic tracking. When a contact visits that page, Mautic records it, and you can segment the contacts who downloaded the file. They are more interested than the average visitor, so their follow-up emails can be more direct.
Live chat connected to Mautic
- Install a chat plugin such as Tawk.to.
- Set up its integration with Mautic.
- When a visitor uses the chat, Mautic receives the messages.
- Segment the visitors who used the chat and send them a specific follow-up.
Troubleshooting the Mautic WordPress integration
Tracking does not work
- Check that HTTPS is active on both sites.
- Confirm that the domain set in Mautic matches the WordPress one (with www or without).
- Clear the browser cache (Ctrl+Shift+Delete).
- Test in a private window.
- Look for JavaScript errors in the developer console (F12).
The Mautic form does not show up on WordPress
- Check that the form ID is correct.
- If the shortcode does not work, use the iframe.
- Disable cache plugins such as W3 Total Cache or WP Super Cache and test again.
Campaigns do not fire
- Check that the Mautic cron jobs are running (
mautic:segments:update,mautic:campaigns:trigger,mautic:emails:send). The full list is in Mautic cron jobs. - Check that SMTP is configured.
- Send a test email manually from Mautic.
- Read the log at
var/logs/mautic_prod.log, inside the Mautic install folder.
Mautic WordPress FAQ
Does the tracking code slow down WordPress?
Very little. The Mautic script is small and loads asynchronously, so the impact on speed is negligible. If you still want to optimize, a plugin that delays script loading takes care of it.
Can I use WPForms forms with Mautic?
Yes, through n8n or Zapier: when a WPForms form is submitted, the workflow sends the data to Mautic. Native Mautic forms are simpler, though, and come already integrated.
How do I track WooCommerce purchases in Mautic?
Use a WooCommerce Mautic integration plugin or Zapier. When a customer buys, sync the purchase value to Mautic and use it in lead scoring, since buyers are worth more points.
Is Mautic tracking a problem for privacy laws?
Mautic tracks with first-party cookies (from your own domain) and respects Do Not Track. For privacy laws such as GDPR or LGPD, add a consent banner, and make sure your privacy policy mentions the tracking.
Can I use Mautic with WordPress Multisite?
Yes. Each site in the network can have its own tracking code, all pointing to a central Mautic instance that tracks several domains. Agencies use this setup a lot.
How do I move WordPress users into Mautic?
Export your WordPress users to CSV with a plugin such as "User Export", then import the file in Mautic under Contacts > Import. Mautic maps the fields automatically.
Where to go from here
Start with the tracking code and one form, confirm that contacts show up in Mautic, and build the campaigns from there. The whole Mautic WordPress stack is open source, with no paid tool in the middle. The official Mautic documentation covers each feature in detail.


