Skip to Content

Marketo

Marketo (now part of Adobe Experience Cloud) is an enterprise marketing automation platform widely used for lead management, email campaigns, and B2B marketing. AttributionHub supports three ways Marketo forms can appear on your site:

  1. Standard DOM forms — Marketo forms rendered as standard HTML elements (.mktoForm) in the page DOM. These are handled by the standard forms handler automatically.
  2. MktoForms2 SDK — When the MktoForms2 JavaScript SDK is present, AttributionHub uses the official addHiddenFields() API to inject attribution data. This is the most reliable method for SDK-based embeds.
  3. Iframe embeds — Marketo forms loaded inside cross-origin iframes are populated by appending attribution data as URL parameters on the iframe source.

AttributionHub detects all three modes automatically — you just need to set up the fields in Marketo.

Prerequisites

Before you begin, make sure:

  • The AttributionHub tracking script is installed on your site (see Installation)
  • You have a Marketo account with admin or form editor access
  • You know your Marketo Munchkin ID and form ID (needed for embeds)

Step 1: Create Custom Fields in Marketo

Attribution values need fields to be stored in. You will create these as custom fields on the Lead (or Person) object.

  1. In Marketo, go to Admin > Field Management
  2. Click New Custom Field
  3. For each attribution field you want to track:
    • Set the Type to String
    • Set the Name to something descriptive (e.g., “Attribution Channel Latest”)
    • Set the API Name to match the AttributionHub field name (e.g., ah_lt_channel)
  4. Click Create and repeat for each field

The API Name is what AttributionHub uses to match and populate the field. Make sure it exactly matches one of the supported field names listed in the Recommended Hidden Fields section.

Step 2: Add Hidden Fields to Your Form

  1. In Marketo, go to Marketing Activities or Design Studio
  2. Open the form you want to edit (or create a new one)
  3. In the form editor, click New Field and search for each custom field you created
  4. Drag each field onto the form
  5. For each field:
    • Right-click on the field and select Field Properties
    • Set Visibility to Hidden (or check a “Hidden” toggle, depending on your Marketo UI version)
    • Leave the default value empty
  6. Click Finish and then Approve and Close

Step 3: Embed the Form on Your Page

Use your existing Marketo embed code. AttributionHub works with both embed methods:

SDK embed (recommended):

<script src="//app-XXXX.marketo.com/js/forms2/js/forms2.min.js"></script> <form id="mktoForm_1234"></form> <script> MktoForms2.loadForm("//app-XXXX.marketo.com", "XXX-XXX-XXX", 1234); </script>

When the MktoForms2 SDK is present, AttributionHub uses MktoForms2.whenReady() together with mktoForm.addHiddenFields() to inject attribution values through the official API. This is the most reliable integration path.

Iframe embed:

<iframe src="https://app-XXXX.marketo.com/index.php/form/YOUR_FORM_ID"></iframe>

For iframe embeds, AttributionHub appends attribution data as URL search parameters on the iframe src.

No changes to your embed code are needed in either case.

Step 4: Test the Integration

  1. Visit a page on your site that contains the Marketo form
  2. Open your browser’s DevTools (F12)
  3. For SDK embeds: check the Console for AttributionHub population messages (if logging is enabled). You can also use MktoForms2.whenReady(function(form) { console.log(form.getValues()); }) in the Console to inspect field values
  4. For iframe embeds: inspect the iframe element and verify that its src URL includes attribution parameters
  5. Submit a test form entry
  6. In Marketo, check the lead record to confirm attribution values were captured

For a full testing walkthrough, see Verify It Works.

How It Works

MktoForms2 SDK

When AttributionHub detects window.MktoForms2, it:

  1. Calls MktoForms2.whenReady() to wait for the form to initialize
  2. Builds an object of field name/value pairs from your field mapping
  3. Calls mktoForm.addHiddenFields() to inject the values via the official API
  4. Marks the form as populated so the standard handler skips it

This approach bypasses DOM manipulation entirely and uses Marketo’s own API, making it the most reliable method.

Iframe Embeds

For iframes hosted on marketo.com, AttributionHub:

  1. Detects the iframe by its src URL
  2. Appends attribution field values as URL search parameters
  3. Updates the iframe src, causing it to reload with pre-filled values

Standard DOM Forms

If a Marketo form is rendered as a standard <form class="mktoForm"> element in the page DOM (without the SDK), the standard forms handler populates it like any other HTML form.

The table below lists the most commonly used fields. For the complete field catalog, see Field Reference.

Core Attribution Fields (Latest Touch)

API NameDescriptionExample Values
ah_lt_channelChannel group (latest touch)Paid Search, Organic Social, Direct
ah_lt_sourceTraffic source nameGoogle, Facebook, Direct
ah_lt_mediumTraffic mediumpaid, organic, social, email
ah_lt_campaignCampaign namespring_sale, Organic Search
ah_lt_contentContent classificationPaid Search Ad, Social Post
ah_lt_termSearch keyword (if available)running shoes
ah_lt_landing_urlLanding page URL (no query string)https://yoursite.com/pricing

Core Attribution Fields (First Touch)

API NameDescriptionExample Values
ah_ft_channelChannel group (first touch)Paid Search, Organic Social
ah_ft_sourceTraffic source nameGoogle, Facebook
ah_ft_mediumTraffic mediumpaid, organic, social
ah_ft_campaignCampaign namelaunch_campaign
ah_ft_landing_urlOriginal landing page URLhttps://yoursite.com/blog/post

Global Fields

API NameDescriptionExample Values
ah_visitor_idUnique visitor ID, persistent across visitsa1b2c3d4-e5f6-7890-abcd-ef1234567890
ah_touch_countTotal number of recorded visits5

For additional fields including latest-non-direct touch (ah_lnd_*), drill-down fields, raw UTM parameters, and ad click IDs, see the full Field Reference.

Custom Field Mapping

If your Marketo custom fields use different API names, override the defaults:

<script> window.attrhub = { settings: { fieldMapping: { "latest.attribution.channelGroup": "attributionChannel", "latest.attribution.source": "leadSource", "latest.attribution.campaign": "campaignName", }, }, }; </script>

See Configuration for the full mapping reference.

Tips

  • Smart Campaigns — Use attribution fields in Smart Campaign filters and triggers. For example, create a campaign that assigns leads from “Paid Search” to your sales team and leads from “Organic Social” to a nurture track.
  • Revenue Cycle Modeler — Include attribution data in your revenue cycle stages for better pipeline analysis.
  • Marketo landing pages — If you host forms on Marketo landing pages, add the AttributionHub script to the landing page template’s custom HTML section.
  • Salesforce sync — If you sync Marketo with Salesforce, create matching custom fields in Salesforce so attribution data flows through to your CRM. Map the Marketo fields to their Salesforce counterparts in the Marketo-Salesforce field mapping settings.
  • Multiple forms on one page — AttributionHub handles all Marketo forms on a page, regardless of embed method.

Troubleshooting

Fields are empty after form submission

  1. Verify that the Marketo custom field API Names exactly match the AttributionHub field names (or your custom field mapping). API names are case-sensitive.
  2. Ensure the custom fields are added as hidden fields in the form editor.
  3. For SDK embeds, verify that MktoForms2 is available on the page by typing window.MktoForms2 in the browser Console.
  4. Enable logging (enableLogging: true in settings) and check the browser Console.

SDK not detected

If AttributionHub is not using the SDK path, it may be because the Marketo script loads after the AttributionHub script. The MktoForms2 SDK must be present in the window object when AttributionHub runs. Try placing the Marketo embed script before the AttributionHub script in your HTML.

Form loads in an iframe unexpectedly

Some CMS integrations embed Marketo forms in iframes even when using the SDK embed code. Check your page in DevTools to determine the actual embed mode. AttributionHub handles both, but the behavior differs slightly (SDK uses addHiddenFields, iframe uses URL parameters).