Marketo (now Adobe Marketo Engage) is a marketing automation platform built around lead scoring, behavioural tracking, and multi-channel nurturing. Connecting it to WordPress gives your site real-time lead capture with automatic CRM sync, visit-level tracking tied to individual contacts, and form submissions that trigger Marketo workflows — without manual CSV exports.
There are three main integration paths: adding the Munchkin tracking script to WordPress (visitor tracking), embedding Marketo Forms 2.0 directly on your pages (lead capture), and pushing data programmatically via the Marketo REST API (custom sync from WooCommerce checkouts, membership signups, or any WordPress event). Most sites use all three together. If you’re also evaluating HubSpot or Zoho CRM as alternatives, see the HubSpot WordPress integration guide and the Zoho CRM WordPress integration guide for side-by-side context.
Before you start: what you need from Marketo
Before touching WordPress, gather these three things from your Marketo account:
- Munchkin ID — your Marketo account’s unique tracking identifier (format:
ABC-123-XYZ). Find it at Admin → Munchkin. - Instance URL / subdomain — your Marketo REST endpoint base, e.g.
https://abc-123-xyz.mktorest.com. Also visible in Admin → Munchkin or Admin → Web Services. - API credentials (for REST access) — a Client ID and Client Secret from a LaunchPoint service. Create one at Admin → LaunchPoint → New Service. Choose type “Custom” and assign an API Only user with the permissions your integration needs (typically Lead and Activity access).
Method 1: Munchkin tracking code
Munchkin is Marketo’s JavaScript tracking library. Once added to your site, it drops a cookie on every visitor and records page visits, link clicks, and form fills as activities on the corresponding Marketo lead record (matched by cookie, and later by email once a form is submitted).
The script from your Marketo account looks like this:
<script type="text/javascript">
(function() {
var didInit = false;
function initMunchkin() {
if (didInit === false) {
didInit = true;
Munchkin.init('ABC-123-XYZ'); // your Munchkin ID
}
}
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//munchkin.marketo.net/munchkin.js';
s.onreadystatechange = function() {
if (this.readyState == 'complete' || this.readyState == 'loaded') {
initMunchkin();
}
};
s.onload = initMunchkin;
document.getElementsByTagName('head')[0].appendChild(s);
})();
The cleanest way to add this to WordPress is via the wp_head action in your child theme’s functions.php:
add_action( 'wp_head', function () {
// Replace ABC-123-XYZ with your Munchkin ID.
?>
<script type="text/javascript">
(function() {
var didInit = false;
function initMunchkin() {
if (didInit === false) { didInit = true; Munchkin.init('ABC-123-XYZ'); }
}
var s = document.createElement('script');
s.type = 'text/javascript'; s.async = true;
s.src = '//munchkin.marketo.net/munchkin.js';
s.onreadystatechange = function() {
if (this.readyState == 'complete' || this.readyState == 'loaded') { initMunchkin(); }
};
s.onload = initMunchkin;
document.getElementsByTagName('head')[0].appendChild(s);
})();
</script>
If you'd rather avoid editing theme files, the Insert Headers and Footers plugin (free) lets you paste the Munchkin snippet into a wp-admin UI field that injects it into <head> sitewide — no PHP required.
Once deployed, verify in Marketo's Lead Database: browse to a page on your site, then check the Munchkin activity log under Admin → Munchkin → Munchkin API for a recent page-visit event.
Method 2: Embed Marketo Forms 2.0
Marketo Forms 2.0 is the recommended way to add lead-capture forms to WordPress pages. The form renders client-side and submits directly to Marketo — no data touches your WordPress server.
In Marketo, go to Marketing Activities → [your form] → Form Actions → Embed Code. The embed code has three parts:
<!-- 1. Load the Forms 2.0 library (once per page) -->
<script src="//app-abc-123-xyz.marketo.com/js/forms2/js/forms2.min.js"></script>
<!-- 2. The form placeholder element -->
<form id="mktoForm_1234"></form>
<!-- 3. Initialize and load the form -->
<script>
MktoForms2.loadForm(
"//app-abc-123-xyz.marketo.com", // your Marketo instance URL
"ABC-123-XYZ", // your Munchkin ID
1234 // your form ID number
);
</script>
To add this to a WordPress page or post:
- In the block editor, add a Custom HTML block where you want the form to appear
- Paste the embed code from Marketo (all three parts) into the Custom HTML block
- Save and preview — the Marketo form renders with Marketo's default styling
To customise the form's appearance to match your site, Marketo Forms 2.0 exposes a CSS class (.mktoForm) and allows you to override styles. You can also hook into form events to trigger analytics or page redirects:
MktoForms2.whenReady(function(form) {
form.onSuccess(function(values, followUpUrl) {
// Redirect to a custom thank-you page instead of Marketo's default.
window.location.href = '/thank-you/';
return false; // Prevent the default follow-up action.
});
});
One practical consideration: the Forms 2.0 library adds around 90 KB to the page. If you're embedding on a landing page where conversion rate is critical, confirm the form load doesn't push your LCP over 2.5 seconds — particularly on mobile. Loading the library asynchronously (as shown above) helps, but test with a tool like PageSpeed Insights after embedding.
Method 3: Marketo REST API with wp_remote_post()
For custom integrations — syncing WooCommerce customers to Marketo as leads, pushing membership signup data, or submitting contact form entries via PHP rather than Marketo's own form — the REST API gives you full control.
Step 1: Get an access token
Marketo uses OAuth 2.0 Client Credentials grant. Exchange your Client ID and Client Secret (from the LaunchPoint service) for a bearer token:
function marketo_get_access_token(): string|false {
// Cache the token in a WP transient — tokens expire after 1 hour.
$cached = get_transient( 'marketo_access_token' );
if ( $cached ) {
return $cached;
}
$client_id = 'YOUR_CLIENT_ID';
$client_secret = 'YOUR_CLIENT_SECRET';
$instance_url = 'https://abc-123-xyz.mktorest.com';
$response = wp_remote_get(
$instance_url . '/identity/oauth/token?grant_type=client_credentials'
. '&client_id=' . $client_id
. '&client_secret=' . $client_secret
);
if ( is_wp_error( $response ) ) {
return false;
}
$body = json_decode( wp_remote_retrieve_body( $response ), true );
if ( empty( $body['access_token'] ) ) {
return false;
}
// Cache for 55 minutes (token validity is 1 hour).
set_transient( 'marketo_access_token', $body['access_token'], 55 * MINUTE_IN_SECONDS );
return $body['access_token'];
}
Step 2: Create or update a lead
Use the /rest/v1/leads.json endpoint with the createOrUpdate action. Marketo deduplicates on email address by default:
function marketo_sync_lead( array $lead_data ): bool {
$token = marketo_get_access_token();
if ( ! $token ) {
return false;
}
$instance_url = 'https://abc-123-xyz.mktorest.com';
$response = wp_remote_post(
$instance_url . '/rest/v1/leads.json',
[
'headers' => [
'Authorization' => 'Bearer ' . $token,
'Content-Type' => 'application/json',
],
'body' => wp_json_encode( [
'action' => 'createOrUpdate',
'lookupField' => 'email',
'input' => [
[
'email' => sanitize_email( $lead_data['email'] ),
'firstName' => sanitize_text_field( $lead_data['first_name'] ),
'lastName' => sanitize_text_field( $lead_data['last_name'] ),
'company' => sanitize_text_field( $lead_data['company'] ?? '' ),
'leadSource' => 'WordPress',
],
],
] ),
]
);
if ( is_wp_error( $response ) ) {
error_log( 'Marketo REST error: ' . $response->get_error_message() );
return false;
}
$body = json_decode( wp_remote_retrieve_body( $response ), true );
return ! empty( $body['success'] ) && $body['success'] === true;
}
// Hook into a WooCommerce order completion to sync the customer as a Marketo lead:
add_action( 'woocommerce_order_status_completed', function ( $order_id ) {
$order = wc_get_order( $order_id );
marketo_sync_lead( [
'email' => $order->get_billing_email(),
'first_name' => $order->get_billing_first_name(),
'last_name' => $order->get_billing_last_name(),
'company' => $order->get_billing_company(),
] );
} );
The REST API rate limit is 50,000 calls per day on standard Marketo plans, with a maximum of 10 calls per second. For bulk lead imports (migration, historical data), use the Bulk Lead Import API instead of the single-lead endpoint.
Method 4: WPForms or Gravity Forms with a Marketo integration
If you'd rather keep your forms built in WordPress (for design consistency and spam protection) rather than using Marketo's hosted forms, native form plugin integrations handle the sync:
- WPForms: The WPForms Marketo addon (requires WPForms Elite) connects to your Marketo account via API credentials and maps form fields to Marketo lead fields per-form. Submissions are pushed to Marketo synchronously on form submit.
- Gravity Forms: The Gravity Forms Marketo plugin (third-party, available on the Gravity Forms marketplace) adds a Marketo feed to each form with field mapping and conditional logic.
- Zapier: Any WordPress form plugin with webhook support can trigger a Zapier zap that creates or updates a Marketo lead. More latency than a direct integration (typically seconds, not milliseconds) but covers any form plugin without a native Marketo integration.
For a comparison of form plugins by integration capabilities, Marketo support, and spam protection, see the WordPress contact form plugins comparison. For reducing bot submissions before they reach Marketo, stopping spam on WordPress forms covers honeypots, CAPTCHA, and server-side validation approaches.
Testing the integration
After setup, test each component:
- Munchkin: Browse your site in an incognito window. In Marketo, go to Lead Database → All Leads and search for "Anonymous" — you should see a new anonymous lead with page-visit activities from your session.
- Forms 2.0 / form plugin: Submit a test form using an email address that doesn't exist in Marketo yet. Wait 30–60 seconds, then search for it in the Lead Database. Confirm the lead source and all mapped fields populated correctly.
- REST API: After a test lead sync, check the lead record in Marketo for the "Lead Source: WordPress" value and any other mapped custom fields.
If leads aren't appearing: check the Marketo activity log for API errors (Admin → Web Services → Error Log), verify the LaunchPoint service user has the correct role permissions, and confirm the access token isn't stale (the transient caching approach above handles this automatically).
Marketo is one of several marketing platforms that integrate well with WordPress. If your stack also involves Mailchimp for email or other CRMs, see the guides to integrating Mailchimp with WordPress contact forms. The infrastructure decisions that affect all outbound integrations — hosting environment, caching, and PHP configuration — are covered in five things to decide before building a WordPress site.


