Last updated on October 18, 2023

WP Forms Google Sheets integration

Don’t know where to add this snippet? Read our guide: How to add code snippets.

Send form data to Google Sheets with WP Forms.

To integrate WP Forms with Google Sheets, you can use the WPForms Google Sheets add-on. This add-on allows you to automatically send form entries from WPForms to a Google Sheets spreadsheet. It’s a great way to keep track of form submissions and easily manage your data.

To get started, follow these steps:

  1. Install and activate the WPForms plugin on your WordPress site.
  2. Install and activate the WPForms Google Sheets add-on from the WPForms website or the WordPress plugin repository.
  3. Go to WPForms » Addons in your WordPress dashboard and click on the “Install Addon” button for the Google Sheets add-on.
  4. Once the add-on is installed and activated, go to WPForms » Settings » Integrations and click on the “Google Sheets” tab.
  5. Click on the “Add New Account” button and follow the prompts to connect your Google account.
  6. After connecting your Google account, you’ll see a list of available Google Sheets spreadsheets. Select the one you want to use for your form entries.
  7. Next, go to WPForms » All Forms and edit the form you want to integrate with Google Sheets.
  8. In the form builder, go to the “Settings” » “Integrations” tab and click on the “Add New Integration” button.
  9. Select “Google Sheets” from the integration options and choose the Google Sheets account you connected earlier.
  10. Map the form fields to the corresponding columns in your Google Sheets spreadsheet.
  11. Save your form and you’re done! Form entries will now be automatically sent to your Google Sheets spreadsheet.

Here’s an example of how to integrate WPForms with Google Sheets using the wpsnippets_wpforms_google_sheets_integration() function:

function wpsnippets_wpforms_google_sheets_integration() {
    // Check if WPForms plugin is active
    if ( class_exists( 'WPForms' ) ) {
        // Check if WPForms Google Sheets add-on is active
        if ( class_exists( 'WPForms_Google_Sheets' ) ) {
            // Add your Google Sheets integration code here
            // ...
        } else {
            // Display a notice if WPForms Google Sheets add-on is not active
            echo 'Please install and activate the WPForms Google Sheets add-on.';
        }
    } else {
        // Display a notice if WPForms plugin is not active
        echo 'Please install and activate the WPForms plugin.';
    }
}

This example code checks if the WPForms plugin and the WPForms Google Sheets add-on are active. If both are active, you can add your Google Sheets integration code inside the function. If either the plugin or the add-on is not active, it will display a notice to install and activate the required components.

Examples

Example 1: Sending WP Forms submissions to Google Sheets using Zapier

This use case demonstrates how to integrate WP Forms with Google Sheets using Zapier. Zapier is a third-party service that allows you to connect different web applications together. By setting up a Zap (a connection between two apps), you can automatically send WP Forms submissions to a Google Sheets spreadsheet.

// No code example needed for this use case.

To achieve this integration, you would need to follow these steps:

  1. Set up a Google Sheets spreadsheet to store the form submissions.
  2. Install and activate the WP Forms plugin on your WordPress site.
  3. Create a new form using WP Forms and configure the form fields.
  4. Sign up for a Zapier account and create a new Zap.
  5. Select WP Forms as the trigger app and choose the “New Form Entry” trigger.
  6. Connect your WordPress site and select the form you want to integrate.
  7. Set up the Google Sheets action app and select the spreadsheet where you want to store the form submissions.
  8. Map the form fields to the corresponding columns in the Google Sheets spreadsheet.
  9. Test the Zap to ensure that the integration is working correctly.
  10. Enable the Zap to start sending WP Forms submissions to Google Sheets.

Example 2: Sending WP Forms submissions to Google Sheets using a custom PHP function

This use case demonstrates how to send WP Forms submissions to Google Sheets using a custom PHP function. By hooking into the appropriate WP Forms action hook, you can retrieve the form data and send it to Google Sheets using the Google Sheets API.

function wpsnippets_send_wpforms_submission_to_google_sheets( $entry, $form_data ) {
    // Code to send the WP Forms submission to Google Sheets using the Google Sheets API.
}
add_action( 'wpforms_process_complete', 'wpsnippets_send_wpforms_submission_to_google_sheets', 10, 2 );

In this example, the wpforms_process_complete action hook is used to trigger the custom PHP function wpsnippets_send_wpforms_submission_to_google_sheets(). This function receives two parameters: $entry (an array containing the form entry data) and $form_data (an array containing the form data). Inside the function, you would write the code to send the WP Forms submission to Google Sheets using the Google Sheets API.

Example 3: Sending WP Forms submissions to Google Sheets using a plugin

This use case demonstrates how to send WP Forms submissions to Google Sheets using a plugin. There are several plugins available in the WordPress repository that provide this functionality, such as “WPForms Google Sheets Connector” and “Formidable Forms – Google Sheets”. These plugins typically offer a user-friendly interface to configure the integration and handle the communication with Google Sheets.

// No code example needed for this use case.

To use this functionality, you would need to:

  1. Install and activate a plugin that provides WP Forms Google Sheets integration.
  2. Configure the plugin settings to connect to your Google Sheets account and select the spreadsheet where you want to store the form submissions.
  3. Select the WP Forms form you want to integrate with Google Sheets.
  4. Map the form fields to the corresponding columns in the Google Sheets spreadsheet.
  5. Save the settings and test the integration to ensure that WP Forms submissions are being sent to Google Sheets correctly.
Last updated on October 18, 2023. Originally posted on December 26, 2023.

Leave a Reply

Your email address will not be published. Required fields are marked *