• Resolved Galyn

    (@galyn)


    I’m using one google form for several websites and I was wondering if there’s a way to add a field to the responses table that includes the site name or URL. This way I can run queries and charts on the spreadsheet based on which site they came from.

    I doubt there’s a way to do this, but I figured I’d ask.

    https://www.ads-software.com/plugins/wpgform/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mike Walsh

    (@mpwalsh8)

    Technically this would be possible although doing so won’t be for the feint of heart. Hopefully what I outline below makes sense. Now I haven’t tried it but in theory it should work.

    1. On your Google Form create a “Select From List” field and a choice for each of the web sites you plan to deploy the form from. I would make the choices very simple answers, maybe even something like “A”, “B”, “C”, etc. because the user will never actually see this question. Leave the Question and Help fields blank and make sure the required field is not checked.
    2. Gather up “prefilled Google Form URLs”, one for each possible choice you created in Step 1 above. More information about prefilled Google Form URLs can be found here.
    3. Determine the ID of the field that holds the Select Entry from the live form. You’ll need to look at the HTML source to find it, it will be something like: entry_915850061
      <select name="entry.915850061" id="entry_915850061"><option value=""></option>
      <option value="A">A</option> <option value="B">B</option> <option value="C">C</option></select>
    4. When defining the form within WordPress, define Form Specific Custom CSS to hide this question that is prefilled using the URL so the user doesn’t see it.
      #entry_915850061 {
          display: none;
      }

    You may need to do some additional CSS but I think this will work in general. Let me know how you make out, it is an interesting problem to try and solve.

    Thread Starter Galyn

    (@galyn)

    That worked brilliantly.

    Prefilled URLs are pretty much straightforward. You just tack on form_field_id=value to the end of the url (remembering to use ? or & as needed to attach the url variable.

    Then I used some jquery to walk to dom and hide the parent div so it hides the label and the input.

    jQuery( “#form_field_id” ).parent().hide();

    That way I still have a column header in the spreadsheet. I also used a text box instead of drop down so I can just change it at anytime without requiring modification of the form anytime I add a new website.

    Thread Starter Galyn

    (@galyn)

    Oh and totally resolved. You’ve always been an extremely helpful dev. Thanks so much Mike!

    Plugin Author Mike Walsh

    (@mpwalsh8)

    Excellent. I love it when a plan comes together!

    Thanks for posting the follow up, I am sure this question will come up again at some point. I too had thought about using jQuery but that subject typically scares people off and the chances for mistakes are much higher.

    Where did you add the jQuery?

    Thread Starter Galyn

    (@galyn)

    I placed it on the page for the form just underneath the shortcode for the form.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘add site name?’ is closed to new replies.