I have a feedback form (newform.aspx) which will be linked to from many different collaboration sites in SP2010 site collection. I would like to capture the referring page and insert it into the form. It doesn't need to be visible to end user, but there's no problem if they can see it. Its simply a matter of convenience rather than ask them to manually input this detail. We are hoping to then have visibility of where the user who left the completed form came from..

I have been able to use:

var myURL = document.referrer; alert (myURL);

to show that the referrer is correct in a popup box, but have had no success in capturing that to the form, and ultimately, the list column. I also understand that document.referrer is not best practise, but my users will only arrive here from internal pages hyperlinked, so it should suit my purposes.

I do have access to designer, but my experience levels are n00b. Can somebody please help? (my first post here, so I apologise if this post is poor etiquette).

2 Answers 2


If I understand you correctly what you will want to do is first have a column for the url to be stored in. By default this column will now be on the Newform.aspx page.

The below code uses Jquery (which you will have to include) or you can edit the code to use just plain Javascript (which will be slightly faster if you are using it just for this).

$(document).ready(function () {
    $("[title='referrerColumn']").css('display','none'); //hides field
    /* Or plain JS
       document.getElementById("SPDynamicIDForAField").value = document.referrer;
      Please note that there are other ways to get the field instead of using ID

When you click save what ever value is in the referrerColumn will be saved.

Using SPD you can create a custom form for the list and set it to be the defualt form which allows you to edit the html/aspx directly


I was able to achieve my requirements by doing the following:

First add a new column called URL (or similar) to your Feedback list. It will be added to the newform.aspx by default and is the intended destination column for the data we want to capture.

Add 2 files to siteassets (or similar)

  1. Feedback_link.txt
  2. Feedback_form.txt

Contents of Feedback_link.txt:

<script type="text/javascript" src="location of jquery.js">
<a href="http://yoursitethathastheform/Lists/Feedback/NewForm.aspx" onclick="ShowPopupDialog(GetGotoLinkUrl(this));return false;">Submit Feedback, or Similar Message to Display</a></script>

Contents of Feedback_form.txt:

<script type="text/javascript" src="location of jquery.js">
ExecuteOrDelayUntilScriptLoaded(function() {
    var field = $("#yourSPFieldTEXTvalue_TextField");

Note - replace 'yourSPFieldTEXTvalue' with the value of ID for the field. The easiest way for me was to enter Developer Tools in browser, select element by click, then click the desired field to update on newform.aspx, and scroll in the dev window to find the long string at id="ct100_m_g_xxxxxxx_TextField"

Add a CEWP (Content Editor Web Part) to the newform.aspx, and link it to Feedback_form.txt, then drag it below the form web part. Add a CEWP to the page where you desire the link to the feedback form. content link it to Feedback_link.txt. Redo this step on as many pages as required.

Optional: My preference is to hide the field from the end user, so it wont be tampered with. Add an additional file Hide_field.txt to siteassets (or similar)

Contents of Hide_field.txt

<script language="javascript" type="text/javascript">
 function findacontrol(FieldName) {
    var arr = document.getElementsByTagName("!");
    for (var i=0;i < arr.length; i++ )
       if (arr[i].innerHTML.indexOf(FieldNametohideURL) > 0)
       {         return arr[i];      }
function hideFields() {
    var control = findacontrol("URL");

Add to the newform.aspx using a HTML Form Web Part linked to the file Hide_field.txt

The result is the user clicks the link, fills the fields presented to them and never even navigates away from their own page. Behind the scenes the page theyre on is captured and saved to the list, so that you can see where the submissions are coming from.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.