Search code examples
zapier

Post to zapier webhook and write to spreadsheet


I am trying to use a zapier webhook to write to a google spreadsheet. Here is the simple html I am using:

<form id="my-form">
    <input type="text" id="name" name="name" placeholder="Name" />
    <input type="text" id="age" name="age" placeholder="Age" />
    <input type="text" id="location" name="location" placeholder="Location" />
    <input type="text" id="date" name="date" placeholder="Date" />

    <button type="submit">Submit</button>
</form>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
    (function($){
        function processForm( e ){
            $.ajax({
                url: 'https://hooks.zapier.com/hooks/catch/2366642/xxx/',
                dataType: 'text',
                type: 'post',
                contentType: 'application/x-www-form-urlencoded',
                data: $(this).serialize(),
                success: function( data, textStatus, jQxhr ){
                    $('#response pre').html( data );
                    console.log(data)
                },
                error: function( jqXhr, textStatus, errorThrown ){
                    console.log( errorThrown );
                }
            });

            e.preventDefault();
        }

        $('#my-form').submit( processForm );
    })(jQuery);
</script>

When I hit the submit button I am getting the test data that I entered into the initial zap being written to the spreadsheet each time. I am wanting the name, age, location and date fields to be written to the spreadsheet instead

I used this tutorial to get started so I suspect I am getting the data from the form to the ajax request properly. Any help appreciated.


Solution

  • In case anyone else runs into this, I had not selected the fields in the Action portion of the zap. Here is an image. Hope it helps others out:

    enter image description here