Featured image for blog post about finding embedded Marketo forms on web pages.

Finding Embedded Forms And Documentation Best Practices

Managing Marketo Forms can quickly become challenging due to them being embeddable on external web pages rather than being restricted to Marketo landing pages. When a form is embedded, it becomes difficult to trace the URLs it is associated with. While creating a smart list or performing a bulk activity export for form fills can capture specific referring URLs, it may not cover web pages with embedded forms that had no submissions. Below are proactive and reactive strategies to effectively manage your forms and discover their locations.

Inspect Element

When you encounter a page with a form and want to identify the Marketo Form ID, inspect the element of the page and search for “mktoForm_”. This will lead you to the form’s location, and the ID follows the underscore. However, manually doing this for each form can be time-consuming. Later in this post, we’ll explore an automated solution.

Add URLs to the Form Description

In my experience as a Marketo Consultant, the description field for programs and assets is often underutilized. For forms, consider using the description field to list all the URLs where a form is embedded. This provides quick access to information for troubleshooting or locating active forms.

Keep a Spreadsheet

This doesn’t have to be an either/or proposition. I would use a spreadsheet or better yet, Airtable, to keep track of where all of my forms are embedded. Having this information in two places ensures redundancy and facilitates sharing with individuals who may not have direct access to Marketo. Spreadsheets also enable sorting, filtering, and tagging forms and pages.

Ask Your Web Team

Depending on your organizational structure, different departments may oversee the website. Whether it’s a dedicated web team, IT, or marketing, those responsible for the content management system should be able to identify which forms are embedded on specific pages.

Scrape Your Site

If your web team isn’t able to pull that information from the CMS, they should be at least able to give you a sitemap (if one isn’t publicly available). Once you have that, you can use Python with the Beautiful Soup module to go through each page url and search for the form id. Below is an example script on how to use this.

import requests
from bs4 import BeautifulSoup
import csv

create_csv = open('new_csv_with_form_ids.csv','w',newline='',encoding='utf-8')
csv_writer = csv.DictWriter(create_csv,fieldnames=['URL','Form ID'])
with open('filewithurls.csv','r',encoding='utf-8') as url_list:
    csv_reader = csv.DictReader(url_list)
    for rows in csv_reader:
        headers = {'User-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36'}
        url = rows['URL']
        response = requests.get(url, headers=headers)
        soup = BeautifulSoup(response.text, 'html.parser')
        target_form = soup.find('form', {'id': True})
        if target_form:
            form_id = target_form['id'].split("_")[1]
            csv_writer.writerow({'URL':url,'Form ID':form_id})
            print("No form with ID found on the page.")

It should be noted that this will not find forms that are embedded on other third party websites which is why tracking them at a local level such as within the asset or with a spreadsheet is so crucial.

Similar Posts