6

I have a custom Google Form i made and an own site. What i need is, after submitting the Google Form, to allow the user access to download a file. This means that you should only be able to access to file if you completed the form.

I have been looking for a way to redirect to a custom URL without showing the URL (so the user cannot copy-paste it and download the file many times) but it is impossible to redirect after the submission (even if the form is embedded).

I even tried to make the form open a pop-up with the file url or something but everything seems impossible to do.

Is there a way to achieve this?

TRDrake
  • 202
  • 1
  • 3
  • 13
  • 5
    No, there is no way to redirect to another URL after a Google Form is submitted. You'd need to use a Web App with an HTML form. You can put an Apps Script Web App into an html iframe tag, although you may get cross domain errors if you do that. Or you can just put an HTML form into your site, with no Web App, and make a POST request to a stand alone Apps Script file. The Apps Script file needs a `doPost(e)` function. Send the answers in the POST payload. I'm assuming that you can put JavaScript into your site, which can do whatever you want. – Alan Wells Jul 04 '18 at 21:41
  • 3
    Send an email in the response that contains a temporary, one-time-use link to the web app with a unique URL parameter. When you generate the URL, cache that parameter for the desired time limit (1s to 6h) and remove it upon serving the file. – tehhowch Jul 05 '18 at 04:04
  • @tehhowch this solution resolves quite good what i need, i will search how to do this. – TRDrake Jul 05 '18 at 20:17

2 Answers2

13
<!-- Normal form embed code, add an ID -->
<iframe id="gform" src="https://docs.google.com/forms/d/e/1FAIpQLSeaiWCc598b3beFhYraf4nNsLgG3bXby_Qne93rHy_Mb_8UIA/viewform?embedded=true" width="640" height="487" frameborder="0" marginheight="0" marginwidth="0" style="margin:0 auto; max-width:100%;">Loading…</iframe>

<script type="text/javascript">
var load = 0;

document.getElementById('gform').onload = function(){
    /*Execute on every reload on iFrame*/
    load++;
    if(load > 1){
        /*Second reload is a submit*/
        document.location = "https://www.google.com/search?q=thanks&tbm=isch";
    }
}
</script>
Zastrich
  • 161
  • 1
  • 6
0

If your embedded form is loaded with a script and the webform can have a redirect on submission i found this answer that worked for me:

This is really a very old thread but if someone needs then can do following workaround:

  1. Create a new HTML page say 'test.html' which will have only code in script tag like as below, please change your HTML page name to final page name in the following code:

    window.parent.location.href = 'final.html';
  2. In Webform form submission setting please redirect the user on above HTML page

So now when the form submits Podio will redirect to the above temporary HTML page and the temporary page will reload the main parent page with the correct HTML page.

https://help.podio.com/hc/en-us/community/posts/212217608/comments/360001462172

Drahcir
  • 19
  • 6