Sitecore 8.1.3, WFFM 8.1.rev. 160304

I have a request to have the "landing page" included on all form data exports that are submitted on our website (Form Reports / Export form data to Excel). The landing page and querystrings are different based on campaigns.

Our site visitors would most likely bounce around several pages on the web site prior to submitting a form so my plan is to create a session variable in the Session_Start method (which I would create) of the global.asax.cs file and pull the current URL and query strings.

If this is the proper approach, is there a way to add the new field a forms template so all current and new forms would have this property rather than going into each form? I looked into adding a line in the FormViewModel.cshtml file such as: @Html.Hidden("LandingPageUrl", "My new session variable") but I do not believe it will pull all the way through to the exports.

Thanks in advance!

  • sitecore generates the report for those fields which is present in the form. the hidden filed can be added with two option - 1) add simple text filed and add CSS for hiding it or use jQuery to hide. 2) create the custom filed and add this to the form . Once filled is added set the value . 1) Use Sitecore Action/custom action to set the value 2) write small code and plug it before 'wffm save' event to set the value.
    – Abhi
    Commented Nov 30, 2017 at 10:58

1 Answer 1


Your best bet is probably to create a custom hidden field. This blog post is a good overview of how to do it:


In summary though you need to:

Add a view model:

public class LandingHiddenField: ValuedFieldViewModel<string>
    public override string Value { get; set; }

    public override void Initialize()
        this.ShowTitle = false;
        var landingpage = HttpContext.Current.Request.Cookies["landingpageurl"];
          this.Value = landingpage;

Add a rendering:

using Sitecore.Forms.Mvc.Html
@model  Client.Forms.ViewModels.LandingHiddenField

@using (Html.BeginField())

    @Html.Hidden("LandingPage", Model.Value);

Add your field to Sitecore here:

/System/Modules/Web Forms for Markters/Settings/Field Types/Custom

Then you can add it to any forms you wish and it should track the value.

Note: I have pulled the value from a cookie instead of session as I think this might be more performant but you can get it from session of elsewhere if you prefer.

  • I actually started with the rockpapersitecore.com pae for the field, thanks for sharing and confirming my approach. Regarding the cookie, I will look into it soon. like always, pulled onto other tasks. I will keep all posted.
    – DanO
    Commented Dec 6, 2017 at 21:31

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.