SOLVED

Re: Capturing Page a Visitor Was on Before Clicking "Contact" and Filling Out a Form

Go to solution
JLines
Level 1

Capturing Page a Visitor Was on Before Clicking "Contact" and Filling Out a Form

Hello Nation,

 

I'm reaching out for help.  I have a single form that I have placed on a "contact us" page as shown here: https://www.airsyspro.com/contact/

 

We have many product pages on our site with calls to action that lead to the contact page. In fact, for better or for worse, "Request a Quote", and "Talk to Expert" all go to that same exact form. Reason being the info our sales team would need to take action is the same for each instance.  The preference is to avoid creating duplicate forms with the same or similar fields.  It's less clean to manage but that is beside the point.  Here is an example of a product page:

https://www.airsyspro.com/products/condensate-drains-for-compressed-air-system/automatic-condensate-...

 

The issue I have now is when a form is submitted, I have no way of knowing what page the visitor was on before they came to the form page. So if they are on the page for PRODUCT X and they click "contact us", when they complete the form I have no way of knowing that PRODUCT X was the page they were interested in.  is there any way to look include the referral page that sent them to the contact page in a hidden field?  I spoke with support and it does not appear there is a way to do this, which is shocking.  This can easily be done in Hubspot for a fraction of the price.  Maybe there is something I'm missing.  I'd love to hear solutions other members are utilizing. 

 

It's also important to note the form-fill data is being synced to salesforce CRM.  That is where all of the lead/opportunity management and reporting is done.

 

I'd prefer to avoid creating duplicate forms for each page. I'd be open to utilizing utm parameters if that's a possibility.

 

Thanks for your time and help!!!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Capturing Page a Visitor Was on Before Clicking "Contact" and Filling Out a Form

MktoForms2.whenReady(function(mktoForm){
  mktoForm.onSubmit(function(mktoForm){
    mktoForm.setValues({
      lastFormReferrerURL : document.referrer
    });
  });
});

 

where lastFormReferrerURL is the name of a Textarea field you create to hold the URL.

 

Btw your pages have an infinite JavaScript loop which is really problematic (it uses so much CPU that it pops up a "Stop this script?" error on my machine). Look in your F12 Console and you'll see it.

View solution in original post

8 REPLIES 8
JLines
Level 1

Re: Capturing Page a Visitor Was on Before Clicking "Contact" and Filling Out a Form

@SanfordWhiteman I know you are very knowledgeable on this topic.  Any help would be greatly appreciated.  I'd love to walk you through what we're trying to achieve and get your feedback.

JLines
Level 1

Re: Capturing Page a Visitor Was on Before Clicking "Contact" and Filling Out a Form

@Amy_Goldfine I've seen some elegant solutions you have suggested.  Would you happen to have any advice?

SanfordWhiteman
Level 10 - Community Moderator

Re: Capturing Page a Visitor Was on Before Clicking "Contact" and Filling Out a Form

MktoForms2.whenReady(function(mktoForm){
  mktoForm.onSubmit(function(mktoForm){
    mktoForm.setValues({
      lastFormReferrerURL : document.referrer
    });
  });
});

 

where lastFormReferrerURL is the name of a Textarea field you create to hold the URL.

 

Btw your pages have an infinite JavaScript loop which is really problematic (it uses so much CPU that it pops up a "Stop this script?" error on my machine). Look in your F12 Console and you'll see it.

JLines
Level 1

Re: Capturing Page a Visitor Was on Before Clicking "Contact" and Filling Out a Form

Thanks @SanfordWhiteman ! I really appreciate your expertise.

 

Forgive me here but I am new to Marketo.  Correct me if I'm wrong, in a nut shell, I add this to the header of each section of my site

 

<script>
MktoForms2.whenReady(function(mktoForm){
  mktoForm.onSubmit(function(mktoForm){
    mktoForm.setValues({
      lastFormReferrerURL : document.referrer
    });
  });
});
</script>

 

Then I go to: admin > field management > New Custom field and create a  text area field named lastFormReferrerURL

 

Then I go and edit my form in the marketing activities area. When I open the field details section in the form editor, I would just add the newly created lastFormReferrerURL field type to hidden.

 

The next step would be to create a field in Salesforce to hold that value and update the flow that handles the mapping from marketo to Salesforce.

 

Am I missing anything there?

SanfordWhiteman
Level 10 - Community Moderator

Re: Capturing Page a Visitor Was on Before Clicking "Contact" and Filling Out a Form

It can't be in the <head>. Must be after the form, since it depends on the global object MktoForms2 (which is created by forms2.min.js).

JLines
Level 1

Re: Capturing Page a Visitor Was on Before Clicking "Contact" and Filling Out a Form

@SanfordWhiteman okay great, so would I place it just before the </head> tag?

SanfordWhiteman
Level 10 - Community Moderator

Re: Capturing Page a Visitor Was on Before Clicking "Contact" and Filling Out a Form

Definitely not there, before the closing </body> tag would be safe (unless you have code that's asychronously injecting the forms JS, which is whole other level of fun).

JLines
Level 1

Re: Capturing Page a Visitor Was on Before Clicking "Contact" and Filling Out a Form

@SanfordWhiteman Thank you so Much!  This solution works perfectly.  I appreciate the fact you took time out of your day to help me.  It speaks volumes.

 

The only thing I did was change the "auto fill" Setting.  I set it to "get value from:" referral parameter and the "parameter name is the api name of the hidden field.  Not sure if it's needed but it worked for me.  Thanks again.