14+ years building on WordPress / Replies in under 5 hours
WordPress 2 min read · Updated July 2026

How to Connect Marketo to WordPress: 2026 Step-by-Step Guide

Photo of Ajay Khandal
Ajay Khandal
WordPress Developer
TL;DR

Three methods to integrate Marketo with WordPress: (1) **Munchkin tracking code** — JavaScript snippet from Marketo Admin → Munchkin; add to WordPress via `wp_head` action in child theme `functions.php` or the Insert Headers and Footers plugin. Tracks all page visits and links clicks, tied to lead records by cookie (then matched by email on form submit). (2) **Marketo Forms 2.0 embed** — from Marketo: Marketing Activities → [form] → Embed Code. Paste the 3-part snippet (library script, `<form id="mktoForm_NNNN">`, `MktoForms2.loadForm(...)`) into a WordPress Custom HTML block. Use `MktoForms2.whenReady()` + `form.onSuccess()` callback to redirect to a custom thank-you page. (3) **REST API with `wp_remote_post()`** — requires a LaunchPoint service (Admin → LaunchPoint → New Service) for Client ID + Client Secret; exchange for a bearer token via `GET /identity/oauth/token?grant_type=client_credentials`; cache token in WP transient (expires 1 hour); push leads via `POST /rest/v1/leads.json` with `action: createOrUpdate` and `lookupField: email`. Rate limit: 50,000 calls/day, 10/second. WPForms Elite and Gravity Forms (third-party addon) have native Marketo integrations that handle OAuth and field mapping via a UI — better for teams that don't want to manage token refresh code. Key gotchas: LaunchPoint user must have Lead + Activity permissions; Munchkin cookies are first-party and respect browser cookie policies; Forms 2.0 library adds ~90 KB — test LCP on mobile after embedding.

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:

  1. Munchkin ID — your Marketo account’s unique tracking identifier (format: ABC-123-XYZ). Find it at Admin → Munchkin.
  2. 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.
  3. 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:

  1. In the block editor, add a Custom HTML block where you want the form to appear
  2. Paste the embed code from Marketo (all three parts) into the Custom HTML block
  3. 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:

  1. 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.
  2. 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.
  3. 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.

Frequently asked questions

Add the Munchkin JavaScript snippet to your WordPress site's element on every page. The cleanest approach is to hook into wp_head in your child theme's functions.php: `add_action('wp_head', function() { /* Munchkin script */ }, 20)`. If you prefer not to edit PHP files, the Insert Headers and Footers plugin (free, wordpress.org) lets you paste the snippet into a wp-admin text field that injects it sitewide. Either way, use the asynchronous version of the Munchkin loader (which Marketo provides by default) so the script doesn't block page rendering. Your Munchkin ID is in Marketo Admin → Munchkin.

Use Marketo Forms 2.0. In Marketo, go to Marketing Activities → [your form] → Form Actions → Embed Code. Copy the three-part snippet: the Forms 2.0 library script tag, a `

` placeholder element, and the `MktoForms2.loadForm()` initialisation call. In the WordPress block editor, add a Custom HTML block where you want the form to appear and paste the entire snippet. The form renders client-side and submits directly to Marketo — no data touches your WordPress server. To redirect visitors after submission instead of using Marketo's default follow-up URL, use the `form.onSuccess()` callback to set `window.location.href` and return false.

You need a Client ID and Client Secret from a Marketo LaunchPoint service. Create one at Admin → LaunchPoint → New Service — choose type 'Custom' and assign it an API Only user with the permissions your integration requires (Lead access for creating/updating leads; Activity access if you need to log activities). Once you have the credentials, exchange them for a bearer token via a GET request to `/identity/oauth/token?grant_type=client_credentials&client_id=...&client_secret=...` on your Marketo instance URL. Tokens expire after 1 hour. In WordPress, cache the token in a WP transient set to 55 minutes so you don't hit the identity endpoint on every form submission. Your instance URL has the format `https://abc-123-xyz.mktorest.com` and is visible in Admin → Munchkin or Admin → Web Services.

No. Adobe/Marketo does not maintain an official first-party WordPress plugin. The recommended integration methods are the official Munchkin tracking code (for visitor tracking), Marketo Forms 2.0 embed (for hosted forms), and the Marketo REST API (for programmatic lead sync). For teams that want a UI-based integration without writing code, WPForms Elite includes a native Marketo addon, and Gravity Forms has third-party Marketo plugins available on its marketplace. Zapier can also bridge any WordPress form plugin to Marketo without a dedicated plugin. Avoid community WordPress plugins that claim to be 'the Marketo plugin' — they are third-party, not maintained by Marketo, and may not stay current with Marketo API changes.

Build your form in WordPress (with Contact Form 7, WPForms, Gravity Forms, etc.) and push the submission data to Marketo via the REST API in a PHP hook. On form submission, call `/rest/v1/leads.json` with `action: createOrUpdate` and `lookupField: email`. Map your form fields to Marketo lead fields in the request body. WPForms Pro and Gravity Forms (via third-party addon) both have native Marketo integrations that handle this automatically with a field-mapping UI — no REST API code required. The REST API approach gives more flexibility (conditional routing, custom field enrichment, deduplication logic) but requires managing OAuth token refresh. If you need a no-code path, Zapier connects any form plugin with webhook support directly to Marketo's lead creation workflow.

Yes. WPForms Elite includes a native Marketo addon — install it from WPForms → Addons → Marketo, enter your Marketo REST API credentials (Client ID, Client Secret, and instance URL from a LaunchPoint service), and each form gets a Marketo connection tab for field mapping. When a form is submitted, the addon handles token exchange and posts the lead data to Marketo automatically. Gravity Forms has a third-party Marketo plugin available from independent developers — it adds a Marketo feed to any form with field mapping and conditional logic. Either approach is preferable to maintaining your own REST API token-refresh code if you don't need custom logic. Zapier is the fallback option if your form plugin doesn't have a native Marketo integration.

Photo of Ajay Khandal

Written by Ajay Khandal

I'm a freelance WordPress developer with 14+ years of experience building, fixing, and speeding up sites for businesses, agencies, and store owners across the US, UK, Europe, and Australia. I specialize in custom themes, WooCommerce, and performance — the kind of work that shows up as faster load times and fewer support tickets. No account managers, no outsourced tickets — you work directly with me, with replies typically inside 5 hours.

Work with me →