Storing the Referrer URL as a Form Field

Manish_Khemani1
Level 3

Hello All,

I need to capture the referring url (entire URL) in a form field on my landing page. I tried using the hidden fields option but it only allows

fields from cookies, url parameters and url parameters from referring urls BUT not the entire referral url.

Is there any option to capture this information?

Best Regards,

Manish Khemani

12 REPLIES 12
Robb_Barrett
Level 10

If you're hoping to capture keywords, no luck. Google and Bing have discontinued including keywords in the referrer. They don't want you to be able to associate a user with a search.  Google webmaster tools are a better bet for getting keywords.

If you're looking to find if they clicked you from a third party place you're in luck. That should still work.

However, just as an FYI, I find it better to write to a list if they're coming from a finite amount of places. This makes for much better reporting and multi-touch attribution. A single field is volatile to get overwritten. Marketo already stores the original referrer by default.

Robb Barrett
Manish_Khemani1
Level 3

Hi Robb,

Thanks for your reply,

My only requirement is only the referrer URL which got the user to my

landing page that contains a marketo form. is there any option to capture

the referrer information from the http header of the landing page and

storing it in a hidden form field?

With Best Regards

Manish Khemani

Tata Consultancy Services

Mailto: manish.khemani@tcs.com

Website: http://www.tcs.com

SanfordWhiteman
Level 10 - Community Moderator

<script>

MktoForms2.whenReady(function(form){

  form.setValues({

    OriginalExternalReferrer : document.referrer

  });

});

</script>

Note the Original Referrer built-in field will capture the acquisition URL, so you want to make sure to disambiguate the field names. In this case I assume you've created a Marketo custom field called Original External Referrer.

N.B. you will never see any external document referrers that are running https:// if your landing page is not also running https://.

Manish_Khemani1
Level 3

Thanks Stan,

My developer recommended minor changes to the code - below

<script src="//app-sji.marketo.com/js/forms2/js/forms2.min.js"></script>

<form id="mktoForm_3389"></form>

<script>MktoForms2.loadForm("//app-sji.marketo.com", "120-PTN-868", 3389, (function(form){

  form.setValues({

  ReferringSite : document.referrer

  })

})

);</script>

The difference from your code being the semicolons removed from the 2nd & 3rd Last lines; He suggested this as correct syntax but the with this syntax it did not store any values in the ReferringSite field; Could you provide me the direction to correct the issue?

Thanks in advance

Manish

SanfordWhiteman
Level 10 - Community Moderator

"Correct syntax" -- that's ridiculous and wrong. Semicolons are always correct syntax after a method invocation.  In certain circumstances they can be omitted, but they are more correct here.  Your developer needs to go back to school on this one.

If you're trying to set the custom field Referrer__c that I see in your form, then obviously that has to be the field that appears in your custom JS:

     Referrer__c: document.referrer

Neither OriginalExternalReferrer nor ReferringSite has any inherent meaning unless they exist in your Marketo instance.

As I said above, I don't recommend using Referrer__c because it is not sufficiently distinct from the built-in Original Referrer. But I guess it's too late for that now.

Manish_Khemani1
Level 3

Thanks Stan for a super-prompt reply, Ill let my developer know this

But how do i confirm that ReferringSite is an inherent field in my marketo

instance? Some guidance on this too please

Thanks a bunch again,

With Best Regards

Manish Khemani

Tata Consultancy Services

Mailto: manish.khemani@tcs.com

Website: http://www.tcs.com

SanfordWhiteman
Level 10 - Community Moderator

ReferringSite would only be in your Marketo instance if you added it in Field Management.

You already have an SFDC field called Referrer__c so you might as well use that, even though I think it isn't as detailed as I would like (technically, if you keep overwriting it on every form fill, it's the "most recent conversion referrer" or something like that).

Manish_Khemani1
Level 3

Hi Stan,

We finally managed to do the following change to the code as per your

guidelines:

I have also marked my developer on this trail; Within the script we are

calling the Loadform followed by Whenready and have checked my Field List

to find ReferringSite field present; Still 'ReferringSite' field did not

capture the referrer info; Are we doing something wrong? Please advise

SanfordWhiteman
Level 10 - Community Moderator

These are the fields on your form:

  1. Campaign__c:
  2. Company:
  3. Content__c:
  4. Country:
  5. Email:
  6. FirstName:
  7. LastName:
  8. Medium__c:
  9. Referrer__c:
  10. Source__c:
  11. Title:

If you use form.setValues(), you have to use one of these fields.

If you use form.addHiddenFields(), you can use other fields that are present in your Marketo instance but have not been added in Form Editor.

Manish_Khemani1
Level 3

Hey Stan,

You are a ROCKSTAR!!!! - It Worked ...

Many Many Thanks ... How can i get to same level of knowledge as you?

Hatss Off

With Best Regards

Manish Khemani

Tata Consultancy Services

Mailto: manish.khemani@tcs.com

Website: http://www.tcs.com

SanfordWhiteman
Level 10 - Community Moderator

Many Many Thanks ... How can i get to same level of knowledge as you?

Full immersion!

Grégoire_Miche2
Level 10

Hi Manish,

You will need a couple of lines of JS code to do this. You will have to capture the referrer and use the forms 2.0 to fill the field.

Forms 2.0 » Marketo Developers

-Greg