Capturing Page a Visitor Was on Before Clicking "Contact" and Filling Out a Form | Community
Skip to main content
Level 2
October 1, 2020
Solved

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

  • October 1, 2020
  • 3 replies
  • 3976 views

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:

airsyspro.com/products/condensate-drains-for-compressed-air-system/automatic-condensate-drain-for-compressed-air/rd11-t-remove-moisture-from-compressor/

 

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!!!

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman
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.

3 replies

JLinesAuthor
Level 2
October 1, 2020

@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.

JLinesAuthor
Level 2
October 1, 2020

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

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
October 1, 2020
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.

JLinesAuthor
Level 2
October 1, 2020

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
October 1, 2020

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).