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:
- Standard DOM forms — Marketo forms rendered as standard HTML elements (
.mktoForm) in the page DOM. These are handled by the standard forms handler automatically. - MktoForms2 SDK — When the
MktoForms2JavaScript SDK is present, AttributionHub uses the officialaddHiddenFields()API to inject attribution data. This is the most reliable method for SDK-based embeds. - 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.
- In Marketo, go to Admin > Field Management
- Click New Custom Field
- 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)
- 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
- In Marketo, go to Marketing Activities or Design Studio
- Open the form you want to edit (or create a new one)
- In the form editor, click New Field and search for each custom field you created
- Drag each field onto the form
- 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
- 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
- Visit a page on your site that contains the Marketo form
- Open your browser’s DevTools (F12)
- 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 - For iframe embeds: inspect the iframe element and verify that its
srcURL includes attribution parameters - Submit a test form entry
- 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:
- Calls
MktoForms2.whenReady()to wait for the form to initialize - Builds an object of field name/value pairs from your field mapping
- Calls
mktoForm.addHiddenFields()to inject the values via the official API - 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:
- Detects the iframe by its
srcURL - Appends attribution field values as URL search parameters
- 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.
Recommended Hidden Fields
The table below lists the most commonly used fields. For the complete field catalog, see Field Reference.
Core Attribution Fields (Latest Touch)
| API Name | Description | Example Values |
|---|---|---|
ah_lt_channel | Channel group (latest touch) | Paid Search, Organic Social, Direct |
ah_lt_source | Traffic source name | Google, Facebook, Direct |
ah_lt_medium | Traffic medium | paid, organic, social, email |
ah_lt_campaign | Campaign name | spring_sale, Organic Search |
ah_lt_content | Content classification | Paid Search Ad, Social Post |
ah_lt_term | Search keyword (if available) | running shoes |
ah_lt_landing_url | Landing page URL (no query string) | https://yoursite.com/pricing |
Core Attribution Fields (First Touch)
| API Name | Description | Example Values |
|---|---|---|
ah_ft_channel | Channel group (first touch) | Paid Search, Organic Social |
ah_ft_source | Traffic source name | Google, Facebook |
ah_ft_medium | Traffic medium | paid, organic, social |
ah_ft_campaign | Campaign name | launch_campaign |
ah_ft_landing_url | Original landing page URL | https://yoursite.com/blog/post |
Global Fields
| API Name | Description | Example Values |
|---|---|---|
ah_visitor_id | Unique visitor ID, persistent across visits | a1b2c3d4-e5f6-7890-abcd-ef1234567890 |
ah_touch_count | Total number of recorded visits | 5 |
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
- Verify that the Marketo custom field API Names exactly match the AttributionHub field names (or your custom field mapping). API names are case-sensitive.
- Ensure the custom fields are added as hidden fields in the form editor.
- For SDK embeds, verify that
MktoForms2is available on the page by typingwindow.MktoForms2in the browser Console. - Enable logging (
enableLogging: truein 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).