SOLVED

Capturing Full URL from Referring Web Page to Form Submit

Go to solution
Brenda_Denting1
Level 2

Hello all. I am having a similar issue that others have had regarding capturing referral URL on form submit. We've read a bunch of other threads about this topic and we can't figure out exactly how to apply those instructions to our special circumstance. 

 

We have a custom Wordpress site and we are moving from ContactForm7 to Marketo Forms. Current ContactForm7 captures full referrer URL and includes it in the email alert to sales, which is super helpful information.

 

The behavior I want:

1) User clicks on a product page, then clicks the "request info" button.

2) We want to pass that product page URL to the WordPress landing page with the new Marketo form embedded on it.

3) User submits the form and the URL from the product page gets passed to our unique custom field (Form URL) we created to capture the URL. 

4) Email alert uses the custom field (Form URL). 

 

Questions: 

1) What type of field should the URL field be? String or URL? 

2) Other posts said to create an HTML block and put in the java script. Where does the HTML block go? On the Marketo form (rich text) or the WordPress product page, or the WordPress form landing page? 

3) What is the javascript I would use? 

 

Thanks in advance!! 

Brenda

2 ACCEPTED SOLUTIONS
SanfordWhiteman
Level 10 - Community Moderator

OK, that code has exactly the same effect as the code posted above. In fact it's more fragile because the hidden field needs to be added to the form in Form Editor if you use setValues() or vals(). Using addHiddenFields() doesn't require the field to be on the form to begin with.

 

whenReady() adds the value to all forms, while the final argument to loadForm() adds the value to only that form.

 

Other than that, these 2 pieces of code are are not substantively different. They both set the value of a hidden field when a form is ready:

 

#1

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

 

#2

MktoForms2.loadForm("//app-ab37.marketo.com", "525-EAQ-286", 1056, function (form) {
  form.vals({
    "lastFormReferralURL" : document.referrer
  });
});

 

View solution in original post

SanfordWhiteman
Level 10 - Community Moderator

I am only able to capture half URL (Example: sensen.ai is the website, if the form filled in sensen.ai/solution/retail, I am only capturing sensen.ai/)


That’s not “half“ of the referrer URL. It’s the protocol + hostname, i.e. the origin.

 

Which is exactly you’d expect to see because https://sensen.ai sends this CSP referrer-policy:

referrer-policy: origin

 

Also please remember to use the syntax highlighter when posting code so it’s readable.

View solution in original post

16 REPLIES 16