Read Time

0

min

Read Time

0

min

Insights

Nov 4, 2025

How to Add Marketo Form to Framer

By adding a Marketo form to Framer, you can easily collect leads, inquiries, support requests, and feedback. It enhances marketing efficiency with customizable forms.

Framer Logo for Blog Authors

Uploaded by

Profile of Blogger Kim Yejeong

Translated by

A blog thumbnail explaining how to efficiently enhance lead collection and inquiry management by integrating Marketo forms in Framer, including a step-by-step guide on adding Marketo forms.
A blog thumbnail explaining how to efficiently enhance lead collection and inquiry management by integrating Marketo forms in Framer, including a step-by-step guide on adding Marketo forms.
A blog thumbnail explaining how to efficiently enhance lead collection and inquiry management by integrating Marketo forms in Framer, including a step-by-step guide on adding Marketo forms.

Contents

Table of Contents

This document aims to help Korean users learn Framer by addressing the lack of Korean materials. We've translated content from the official blog into Korean and included practical information. We hope this is somewhat helpful for all Framer users.

Why add a Marketo form?

By adding a Marketo form to your Framer website, you can capture leads and manage marketing more efficiently. Follow the steps below to connect it to your site using a custom code component.

Adding a Marketo form to your site

1. Create a form in Marketo

First, visit the Marketo website and log in or create an account. Refer to this guide to design a custom form.

Marketo의 웹사이트로, 이 사이트에서 폼을 생성하는 방법을 설명합니다.

2. Get the embed code

After creating your form, obtain the embed code following this guide.

Marketo에서 임베드 할 코드를 가져오는 방법을 설명합니다.

3. Add a custom code component in Framer

  1. Go to the Assets panel in Framer and choose "Code".

  2. Click "Create Code File" and replace the default code with the script below.

import { addPropertyControls, ControlType, RenderTarget } from "framer"
import { useState, useEffect } from "react"
import { SettingsMessage } from "<https://framer.com/m/Utils-QTIc.js@PVRWqcAS5FromVQ03eYl>"

/**
 * @framerDisableUnlink
 *
 * @framerSupportedLayoutWidth any-prefer-fixed
 * @framerIntrinsicWidth 600
 * @framerSupportedLayoutHeight any-prefer-fixed
 * @framerIntrinsicHeight 300
 */
export default function MarketoForm(props) {
    const { embed, style } = props
    const [isEmbedValid, setIsEmbedValid] = useState(false)
    const [formId, setFormId] = useState(null)
    const [script, setScript] = useState(null)
    const [isLoading, setIsLoading] = useState(true)

    if (!embed || embed.length === 0) {
        return (
            <SettingsMessage
                title="Marketo Embed Component"
                description="Enter the Marketo Embed Code here"
                containerStyle={style}
            />
        )
    }

    useEffect(() => {
        setIsLoading(true)
        const embedRegex =
            /MktoForms2\\.loadForm\\("(.+?)", "(.+?)", (\\d+)(?:, .+?)?\\);/
        const embedMatch = embed.match(embedRegex)
        const [, link, value, id] = embedMatch || []

        setFormId(`mktoForm_${id}`)

        const embedFirstLine = `<script src="${link}/js/forms2/js/forms2.min.js"></script>`
        const isValidEmbed =
            embed.startsWith(embedFirstLine) && value && id && link
        setIsEmbedValid(isValidEmbed)

        if (isValidEmbed) {
            const newScript = document.createElement("script")
            newScript.src = `${link}/js/forms2/js/forms2.min.js`
            newScript.async = true

            const handleError = (error, message) => {
                setIsEmbedValid(false)
                setIsLoading(false)
                console.error(message, error)
            }

            const handleScriptLoad = () => {
                try {
                    if (window.MktoForms2) {
                        window.MktoForms2.loadForm(link, value, id)
                    }
                } catch (error) {
                    handleError(error, "Error loading form:")
                }
            }

            newScript.onload = handleScriptLoad
            document.body.appendChild(newScript)
            setScript(newScript)

            try {
                document.body.appendChild(newScript)
                setScript(newScript)
            } catch (error) {
                handleError(error, "Error appending script:")
            }
        }
        setIsLoading(false)

        return () => {
            if (script) {
                try {
                    document.body.removeChild(script)
                } catch (error) {
                    setIsEmbedValid(false)
                    console.error("Error removing script:", error)
                }
            }
        }
    }, [embed])

    return (
        <>
            {isLoading ? (
                <></>
            ) : isEmbedValid ? (
                <>
                    <style>{customCSS}</style>
                    <form id={formId} />
                </>
            ) : (
                <SettingsMessage
                    title="Your embed code is incorrect!"
                    description="Update the Marketo embed form in the component property."
                    containerStyle={style}
                    icon={"🚨"}
                />
            )}
        </>
    )
}

const customCSS = `
    .mktoLabel {
        width: auto !important;
        float: none !important;
        display: block !important;
    }
`

MarketoForm.displayName = "Marketo Form"

addPropertyControls(MarketoForm, {
    embed: {
        title: "Embed Code",
        type: ControlType.String,
        displayTextArea: true,
        description:
            "[Where to find my Marketo embed form](<https://experienceleague.adobe.com/en/docs/marketo/using/product-docs/demand-generation/forms/form-actions/embed-a-form-on-your-website>).",
    },
})

4. Input the embed code

  1. Select the Marketo form component you just added in your Framer project.

  2. In the Embed Code input field on the right property panel, paste the code copied from Marketo, and you're done.

Use cases for Marketo forms in Framer

  • Lead Generation: Expand your email list using custom forms.

  • Contact Forms: Make it easy for visitors to reach out and consider adding placeholders for guidance.

  • Support Requests: Simplify support by organizing requests with a straightforward form.

  • Feedback Collection: Gather insights on product features or improvements.

By following these steps, you can seamlessly integrate Marketo forms into a Framer site.
If any issues arise during setup, contact the support team through Framer's Contact Page.

This post is a translation and adaptation of the Framer official blog's 'Adding Marketo Forms to your site'.

Share Blog

Share Blog

Become a
Framer Expert

Any expert capable of Framer outsourcing can apply.
We connect experts and clients directly, with no intermediary fees.

Become a
Framer Expert

Any expert capable of Framer outsourcing can apply.
We connect experts and clients directly, with no intermediary fees.

Become a
Framer Expert

If you are an expert available for Framer freelance work,
anyone can apply.
No intermediary fees, we directly connect
experts and clients.