Integrate WIX form with CRM

To integrate the ZNICRM WebLead API with WIX 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 KeyHow 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: Enable Dev Mode in Wix

  • Go to your Wix site editor.
  • Click on Dev Mode in the top menu and turn on Velo.

Step 3: Create a Custom Form

Use input elements (text fields, dropdowns, etc.) and a Submit button.

Give each input field an ID, like:

  • #inputName
  • #inputPhone
  • #inputEmail
  • #inputQuery

Step 4: Add Backend Web Request

In the left panel:

  • Go to Backend ➜ Right-click ➜ Add a new file named: weblead.jsw

Paste this code inside:

// backend/weblead.jsw
import { fetch } from 'wix-fetch';

export function submitLeadToCRM(leadData) {
    const apiKey = "YOUR_SECRET_API_KEY"; // Do NOT expose on frontend

    const {
        leadName,
        leadPhone,
        leadEmail,
        department = "",
        leadQuery,
        leadConversionPage = "",
        leadIP = ""
    } = leadData;

    if (!leadPhone && !leadEmail) {
        return Promise.reject("Either Phone or Email is required");
    }

    const params = new URLSearchParams({
        apikey: apiKey,
        leadName,
        leadPhone,
        leadEmail,
        department,
        leadQuery,
        leadConversionPage,
        leadIP
    });

    const url = `https://api.intueri.io/weblead.php?${params.toString()}`;

    return fetch(url, { method: "get" })
        .then(res => res.text())
        .catch(err => {
            console.error("Error sending lead:", err);
            throw new Error("Failed to send lead to CRM");
        });
}

Frontend Page Code

On your form page, use this code:

import { submitLeadToCRM } from 'backend/weblead';

$w.onReady(() => {
    $w('#submitButton').onClick(() => {
        const leadData = {
            leadName: $w('#inputName').value,
            leadPhone: $w('#inputPhone').value,
            leadEmail: $w('#inputEmail').value,
            leadQuery: $w('#inputQuery').value,
            department: "1", // optional
            leadConversionPage: "https://yourdomain.com/form-page"
        };

        // Optional: Get IP from external service
        fetch('https://api64.ipify.org?format=json')
            .then(res => res.json())
            .then(data => {
                leadData.leadIP = data.ip;
                return submitLeadToCRM(leadData);
            })
            .then(response => {
                console.log("CRM Response:", response);
                // Show success to user
                $w('#successText').show();
            })
            .catch(error => {
                console.error("Submission error:", error.message);
                // Show error to user
                $w('#errorText').show();
            });
    });
});