Connect Google Forms to Groundhogg
This guide will walk you through the process of integrating a Google Form with Groundhogg by sending form responses to Groundhogg’s Webhook Listener. Once connected, you can trigger automations, create contacts, and manage data directly in Groundhogg.Google Forms doesn’t natively support webhooks, so you’ll need to use Google Apps Script to bridge the gap. Below is a step-by-step guide using Google Apps Script, which is a common and free method to achieve this.
Prerequisites
- A Google account with a Google Form created (or create one during the process).
- A WordPress site with Groundhogg installed and activated.
- The Groundhogg Advanced Features plugin installed and activated (webhooks require this).
- Basic familiarity with Google Forms and Groundhogg’s funnel builder.
Step 1: Set Up Your Google Form
- Create or Open a Google Form:
- Go to Google Forms.
- Either create a new form or open an existing one.
- Add the fields you want to capture (e.g., First Name, Email, Phone). Ensure each field has a clear, unique question title.
- Test the Form:
- Fill out and submit the form at least once to generate sample data. This will help later when mapping fields in Groundhogg.
Step 2: Configure Groundhogg’s Webhook Listener
- Log in to Your WordPress Admin Dashboard:
- Navigate to your WordPress site where Groundhogg is installed.
- Create a New Funnel:
- Go to Groundhogg > Funnels in the WordPress dashboard.
- Click Add New and select Start from Scratch. Name your funnel (e.g., “Google Form Integration”).
- Add the Webhook Listener Benchmark:
- In the funnel builder, drag the Webhook Listener benchmark from the left sidebar (under Benchmarks) into the funnel flow.
- This is the starting point for capturing data from your Google Form.
- Copy the Listener URL:
- Once the Webhook Listener is added, click on it to open its settings.
- You’ll see a Listener URL field with a unique URL (e.g., https://yourdomain.com/wp-json/groundhogg/v3/webhooks/...).
- Copy this URL to your clipboard. This is where Google Form data will be sent.
- Save the Funnel:
- Click Save in the funnel builder to activate the Webhook Listener. (You’ll configure field mapping later after sending test data.)
Step 3: Set Up a Google Apps Script to Send Webhook Data
Google Forms doesn’t natively support webhooks, so you’ll use Google Apps Script to send form responses to Groundhogg’s Webhook Listener.
- Open the Google Form Script Editor:
- In your Google Form, click the three-dot menu (⋮) in the top-right corner.
- Select Script Editor. This opens a new tab with a blank script.
- Add the Webhook Script:
- Replace the default code with the following script. Replace YOUR_WEBHOOK_LISTENER_URL with the Listener URL you copied from Groundhogg:
function onFormSubmit(e) { // Replace this with your webhook URL var webhookUrl = "https://your-webhook-endpoint.com"; // Get form response data var formResponse = e.response; var itemResponses = formResponse.getItemResponses(); // Build the payload var payload = { "timestamp": formResponse.getTimestamp().toISOString(), "responses": {} }; // Loop through each form response and add it to the payload for (var i = 0; i < itemResponses.length; i++) { var itemResponse = itemResponses[i]; payload.responses[itemResponse.getItem().getTitle()] = itemResponse.getResponse(); } // Send the data to the webhook URL var options = { "method": "post", "contentType": "application/json", "payload": JSON.stringify(payload) }; UrlFetchApp.fetch(webhookUrl, options); }
- Replace the default code with the following script. Replace YOUR_WEBHOOK_LISTENER_URL with the Listener URL you copied from Groundhogg:
- Save the Script:
- Click the disk icon or go to File > Save. Name your project (e.g., “Groundhogg Webhook”).
- Set Up a Trigger:
- In the Script Editor, click the clock icon (Triggers) in the left sidebar.
- Click + Add Trigger in the bottom-right corner.
- Configure the trigger:
- Choose which function to run: onSubmit.
- Choose which deployment: Head (default).
- Select event source: From form.
- Select event type: On form submit.
- Click Save. You may need to authorize the script by signing in with your Google account and granting permissions.
- Test the Script:
- Go back to your Google Form, submit a test response, and ensure the script runs without errors. (You’ll verify the data in Groundhogg later.)
Step 4: Map the Data in Groundhogg
- Check for Incoming Data:
- Return to your WordPress dashboard and open the funnel you created in Groundhogg.
- Click on the Webhook Listener step.
- In the settings, look at the Request section. After your test submission, it should display the data sent from the Google Form (e.g., { "First Name": "John", "Email": "john@example.com" }).
- Map the Fields:
- Click the Map Request Fields button in the Webhook Listener settings.
- Match the Google Form question titles (e.g., “First Name”, “Email”) to Groundhogg contact fields (e.g., first_name, email).
- If a field doesn’t exist in Groundhogg, you can create a custom field first.
- Click Save Changes after mapping all fields.
- Add Automation Steps (Optional):
- After the Webhook Listener, add actions to your funnel (e.g., Apply Tag, Add Note, or Send Email) to process the incoming data.
- Save the funnel again.
Step 5: Test the Integration
- Submit Another Test Response:
- Go back to your Google Form and submit a new response with different data.
- Verify in Groundhogg:
- Go to Groundhogg > Contacts in your WordPress dashboard.
- Check if a new contact was created with the mapped data from your test submission.
- If you added automation steps (e.g., applying a tag), confirm they executed correctly.
You’ve successfully connected your Google Form to Groundhogg using the Webhook Listener! Form submissions will now automatically send data to Groundhogg, where you can manage contacts and trigger automations.