Connect Google Form or Google Sheets With CRM

To integrate the ZNICRM WebLead API with Google Forms, follow these steps:

Step 1: Generate Your ZNICRM API Key

  1. Log in to your ZNICRM dashboard.
  2. Navigate to Settings.
  3. In the left menu, select Developers → API Key. How To Generate API Key For CRM
  4. Click the “Add Key” button to generate a new API key.
  5. Copy and securely store the generated API key.

Step 2: Create and Link Your Google Form

  1. Create your Google Form with the necessary fields (e.g., Name, Email, Phone).
  2. Click on the Responses tab.
  3. Click the “Link to Sheets” icon to create a linked Google Sheet that will store form responses.

Set Up Google Apps Script

  1. Open the linked Google Sheet.
  2. Click on Extensions → Apps Script.
  3. Delete any existing code in the script editor and replace it with the following:
function onFormSubmit(e) {
  var responses = e.values;

  // Adjust indices based on your form's structure
  var leadName = responses[1];  // Assuming 'Name' is the second column
  var leadEmail = responses[2]; // Assuming 'Email' is the third column
  var leadPhone = responses[3]; // Assuming 'Phone' is the fourth column

  var apiKey = 'YOUR_API_KEY'; // Replace with your actual API key
  var departmentId = ''; // Optional: Replace with your department ID if applicable
  var leadQuery = 'Form submission from Google Forms';
  var leadConversionPage = 'Google Form';
  var leadIP = ''; // Optional: You can capture the IP if available

  var params = {
    apikey: apiKey,
    leadName: leadName,
    leadEmail: leadEmail,
    leadPhone: leadPhone,
    department: departmentId,
    leadQuery: leadQuery,
    leadConversionPage: leadConversionPage,
    leadIP: leadIP
  };

  var queryString = Object.keys(params)
    .map(function(key) {
      return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
    })
    .join('&');

  var url = 'https://api.intueri.io/weblead.php?' + queryString;

  try {
    var response = UrlFetchApp.fetch(url);
    Logger.log('Response: ' + response.getContentText());
  } catch (error) {
    Logger.log('Error: ' + error);
  }
}

Note: Adjust the responses indices to match the order of your form fields. The first element (responses[0]) is the timestamp.

Step 4: Set Up a Trigger for Form Submissions

  1. In the Apps Script editor, click on the Triggers icon (clock symbol) in the left sidebar.
  2. Click “+ Add Trigger”.
  3. Set the following:
    • Choose which function to run: onFormSubmit
    • Choose which deployment should run: Head
    • Select event source: From spreadsheet
    • Select event type: On form submit
  4. Click Save and authorize the script when prompted.

Test the Integration

  1. Submit a test entry through your Google Form.
  2. Check your ZNICRM dashboard to verify that the lead has been created.
  3. In the Apps Script editor, view the Logs (via View → Logs) to see the response from the API.

Additional Notes

  • Mandatory Fields: Ensure that either leadPhone or leadEmail is provided, as at least one is required by the API.
  • Rate Limiting: The API allows up to 60 requests per minute.
  • Error Handling: Consider enhancing the script with additional error handling and notifications as needed.
  • Full API documentation is available at https://hd.znicrm.com/art/weblead-api