Search form

Capture the submission page URL when a Drupal 7 webform is submitted

This lesson shows you a way to capture the submission page when someone submits a Drupal 7 webform on your website. This is useful if you have a webform in a block on multiple pages, and you want to know which page someone was on when they submitted the page.

Here's a scenario:

  • You have created a product enquiry form using the Webform module in Drupal 7.
  • You have configured the webform to be available as a block, and placed that block on all product pages.
  • When the form is submitted by a visitor to your website, you want to track which page the visitor was on when they completed the form.

To do this:

  • Add a Hidden field component to your webform. Give it a name such as "Page where form completed".


  • In the Default Value field, click Browse available tokens. If you don't see this option, you'll need to install the Token module first.


  • In the list of tokens, look for a section called Current Pager (as shown above), then choose one of the tokens from there, e.g.
    • [current-page:title]
    • [current-page:url]
    • [current-page:url:absolute]

      Note that you can add any token from the list that you like, including field values for the node. However, you'll need to make sure that the field actually has a value for that node type, otherwise the field will be empty when the form is submitted.

  • Copy and paste your chosen token into the Default Value field. I recommend you only place one token in this field. Add extra hidden fields if you want to track more than one token. This will make it easier to analyse your data later, particularly if you export the webform results to a CSV file.
  • Finally, choose the Display option (either Secure Value or Hidden Element). Secure Value is the best option if you're using tokens here.


  • Click Save Component.

Now, when someone fills in the form, the submission will include the page they were on when they submitted it.

Our Comment Policy.

We welcome your comments and questions about this lesson. We don't welcome spam. Our readers get a lot of value out of the comments and answers on our lessons and spam hurts that experience. Our spam filter is pretty good at stopping bots from posting spam, and our admins are quick to delete spam that does get through. We know that bots don't read messages like this, but there are people out there who manually post spam. I repeat - we delete all spam, and if we see repeated posts from a given IP address, we'll block the IP address. So don't waste your time, or ours. One other point to note - if you post a link in your comment, it will automatically be deleted.

Add a comment to this lesson

Comments on this lesson

Add comment