Form / Lead Attribution

Hi everyone, we have a single form that generates leads on our website, but it is on many pages of our website related to different topics. I want to relate the form on specific pages to a specific campaign. I can see the different pages this form is on when I scroll down on the form and see “Conversion pages.” How can I relate the leads that come through from each page to their respective campaign?

Hi @alexagatiss, I hope that you are well!
Great question, thanks for asking the HubSpot Community!
First, for information, I’d like to share these resources:
- Associate assets and content with a campaign
- Manage leads
- Campaigns | Frequently Asked Questions
Also, these threads might help you:
- The solution from @louischausse on this post “Tracking lead sources and campaign sources
- The solution from @karstenkoehler on this post “How do I see what leads came from each source?
- The solution from @Phil_Vallender on this post “Tracking lead sources and conversions
Let us know how this goes for you!
Have a great weekend @alexagatiss! :sun_with_face:
Warmly,
Bérangère

Hi @BérangèreL ,

Thank you for getting back to me! These are great resources, thank you for the roundup.

I read through all of them and unfortunately, I wasn’t able to figure out my specific situation using them. I am able to associate all of my assets with the campaign tool, but am at a loss for tracking leads from the website form submission. The website is not built on HubSpot and as far as I can tell it is the same form just on different pages. I want to associate the different pages to different campaigns, though it is the same form.

Basically, I am hoping to completely set up the campaigns so that I am utilizing all that the tool has to offer for reporting. Currently, the campaign “leads generated” fields are blank since this web forms is our primary method of lead generation and I can’t figure out how to associate it. I added each page as “external web” assets to different campaigns, but don’t think that will track when leads come in.

One solution that theoretically would work would be scrap the current form and make individual forms for each page but we have so many pages and this would take so much work, so my fingers are crossed for a different solution :slightly_smiling_face:

@alexagatiss Hi! Another idea would be to use hidden form fields to track which campaign a lead is associated with based on the page they submitted the form from.

Here’s how to implement this:

  1. Edit your form in HubSpot and add a hidden field for “Campaign Name” or “Campaign ID”
  2. Use HubSpot’s JavaScript to dynamically populate this hidden field based on the page URL

Here’s a specific implementation approach:

  1. In HubSpot, go to Marketing → Lead Capture → Forms
  2. Select and edit your form
  3. Add a new form field, select “Hidden” as the field type
  4. Use an existing “Campaign” property or create a custom property
  5. Save your form

Then, add JavaScript to your pages that will set the value of this hidden field based on the page URL. You can add this code to the HubSpot tracking code settings or directly on each page:

javascript

window.addEventListener('load', function() {
 // Get current page URL
 var currentPage = window.location.pathname;

 // Set campaign value based on URL
 if (currentPage.includes('/product-a/')) {
 jQuery('input[name="campaign"]').val('Product A Campaign');
 } else if (currentPage.includes('/service-b/')) {
 jQuery('input[name="campaign"]').val('Service B Campaign');
 } else if (currentPage.includes('/solution-c/')) {
 jQuery('input[name="campaign"]').val('Solution C Campaign');
 }
 // Add more conditions as needed
});

This approach allows you to:

  • Use a single form across multiple pages
  • Track which campaign each lead belongs to based on where they submitted the form
  • Segment and report on leads by campaign in HubSpot

Let me know if this works for you!