Finding Embedded Forms and Documentation Best Practices
Managing Marketo Forms can be challenging, especially when they’re embedded on external pages. This guide covers proactive and reactive strategies for managing forms and locating their embedded URLs.
Inspect Element
To identify a Marketo Form ID on a page, use "Inspect Element" and search for "mktoForm_". The ID follows the underscore. This method is useful for occasional checks but can be time-consuming if you have many forms.
Add URLs to the Form Description
Consider using the description field within Marketo’s form assets to record URLs where each form is embedded. This provides easy access to information for troubleshooting and locating forms quickly.
Keep a Spreadsheet
Maintain a spreadsheet or, better yet, use Airtable to track form locations. This redundancy helps maintain an organized record, especially when sharing with team members who may not have access to Marketo.
Ask Your Web Team
Different departments may oversee the website. Ask the team responsible for the CMS to identify pages with embedded forms.
Scrape Your Site
If the web team can provide a sitemap, you can use Python and Beautiful Soup to check each page URL for embedded forms. The following script demonstrates how to do 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'])
csv_writer.writeheader()
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'}
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})
else:
print("No form with ID found on the page.")
create_csv.close()
Note that this method may not find forms embedded on third-party websites, underscoring the importance of tracking form URLs within Marketo or a spreadsheet.