How to Get Product Title and URL Automatically in Divi Forms

December 5, 2025 - TechnoCrackers
Blog Icon
How to Get Product Title and URL Automatically in Divi Forms

If you’re building websites with Divi and want your forms to automatically include the current page title and URL, this tutorial will help you do it—without using plugins.
This technique is especially useful for:

  • Product pages
  • Landing pages
  • Service request forms
  • Support or inquiry forms

Once set up, users can submit a form and you’ll automatically receive which page they sent it from — making communication faster and more organized.

Step 1 — Edit the Page Using Divi Builder

Open the page where you want this functionality and click:

Enable Visual Builder → Edit With Divi

Create a simple layout with:

  • Section
  • Row
  • Heading Module
  • Contact Form Module

Step 2 — Add the Dynamic Page Title

In the heading module:

  1. Go to Content → Heading
  2. Select: Page/Archive Title (this pulls the current page title dynamically)
  3. Now go to: Advanced → CSS ID & Classes
  4. Add this class: page_title

This class is important because our script will detect it and use its value.

Add the Dynamic Page Title

Step 3 — Create the Divi Form Fields

Open the Contact Form module and add your normal inputs (Name, Email, Message, etc.)

Then add two additional hidden (or visible) fields:

Field Name Field ID
Page URL page_url
Page Title page_title

Example message pattern:

Name: %%Name%%
Email: %%Email%%
Message: %%Message%%
Page Title: %%page_title%%
Page URL: %%page_url%%

This ensures the captured data appears in your submitted email.

Divi Form Fields

Step 4 — Add the Script in Divi Theme Options

Go to:      Divi → Theme Options → Integration → Add Code to <head>

Paste the following scripts:

Script to Fetch Page URL :

 

<script>
document.addEventListener("DOMContentLoaded", function () {
const field = document.querySelector('input[data-original_id="page_url"]');
if (field) field.value = window.location.href;
});
</script>

Script to Fetch Page Title :

<script>
document.addEventListener("DOMContentLoaded", function () {
  const product = document.querySelector('.page_title');
  const field = document.querySelector('input[data-original_id="page_title"]');
  if (product && field) {
      field.value = product.innerText.trim();
      field.readOnly = true;
      field.style.cursor = "not-allowed";
  }
});
</script>

code sample

Step 5 — Test the Form

Now refresh the page and you’ll see:

  • The page title fills automatically
  • The page URL fills automatically
  • The fields are locked so users can’t modify them

Example Front-End Result

Front-End Result

Submit the form and check your email — you should now receive something like this:

Name: John Doe
Email: [email protected]
Message: I want more info.
Page Title: Sample Page
Page URL: https://example.com/sample-page/

Example Mail Result

Mail Result

Want This for WooCommerce?

You can use the same method on product pages — great for product inquiry forms.

 Tip

If you want to hide the title/URL fields, simply hide fields via css.

If you’re planning a WordPress or WooCommerce project that involves Divi forms, dynamic product data, or custom automation, our team can handle the complete development—from planning and implementation to testing and launch.

You can Book a Free Project Consultation to discuss your goals, timelines, and how we can take full responsibility for building your solution.

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Contact us

Let's Unleash Your Digital Potential Together.

Address

C-605, Ganesh glory 11, Nr. BSNL Office, Jagatpur Road, S.G. Highway, Jagatpur, Ahmedabad, India - 382481.

Phone

INDIA : (091) 8200639242 USA : +1 (310) 868-6009

Limited Time Offer

X

Try a Free 2-Hour Test Task

Experience our quality, speed, and communication on any small WordPress task before you commit. No contract. No cost. No obligation.
[For New Agency Partners]

"*" indicates required fields

Name*
0
Would love your thoughts, please comment.x
()
x