If you are running Adobe Commerce (formerly Magento B2B), you already know the complexity of modern wholesale operations. You are likely managing corporate "Company Accounts," dealing with tiered negotiated catalogs, and configuring custom buyer roles.
But here is where most merchants trip over: Operational latency.
When a large B2B wholesale buyer registers on your site, waiting for a human administrator to manually copy-paste their registration data into an enterprise CRM is a liability. Leads go freezing cold in hours.
The immediate corporate reflex is to reach out to expensive SaaS ecosystems like HubSpot or Salesforce, setting up complex synchronization modules that rack up massive per-user monthly licensing fees.
But what if your actual sales team already lives inside Google Workspace? What if they spend 90% of their day inside Gmail, Google Contacts, and Google Sheets?
Instead of adding another costly, heavy layer to your software stack, you can turn your existing Google Workspace ecosystem into an automated, serverless B2B CRM.
In this article, we’ll walk through the architectural blueprint to capture a live Magento 2 customer registration and push it natively into a "Sales Lead Pipeline" in Google Sheets while generating a rich contact profile via the Google People API—with zero third-party middleware overhead.
The Serverless Architecture
Instead of polling APIs or running heavy cron jobs, this pipeline relies on a pure event-driven, real-time mechanism:
[Magento 2 B2B Event]
│
▼ (Secure HTTPS POST with Token)
[Google Apps Script (doPost)]
│
├───► Google Sheets CRM
│
└───► Google People API
-
The Trigger: A customer successfully registers, or a B2B corporate account is saved (
customer_register_successorcompany_save_afterevent in Magento). - The Payload: Magento dispatches a secure JSON webhook containing the name, email, company name, phone number, and a pre-shared authentication token.
- The Ledger: Google Apps Script catches the payload, validates the token, appends the data to a Google Sheet row, and instantly pushes a new contact into the corporate directory.
Step 1: Prepping the Google Apps Script Backend
To interact with your organization's Google Contacts programmatically, you need to leverage the Google People API service inside Apps Script.
- Open a new Google Sheet (Name it something like MageSheet B2B CRM).
- Go to Extensions > Apps Script.
- In the left sidebar, click the + icon next to Services.
- Select People API and click Add.
Now, replace the default code inside Code.gs with the following production-ready script:
// Code.gs
// A pre-shared secure token to validate incoming requests from Magento
const SECURE_TOKEN = "MAGESHEET_B2B_CRM_SYNC_2026";
function doPost(e) {
try {
const payload = JSON.parse(e.postData.contents);
// Security check to prevent unauthorized endpoints from hitting your script
if (payload.token !== SECURE_TOKEN) {
return ContentService.createTextOutput("Forbidden").setStatusCode(403);
}
const customer = payload.customer_data;
// 1. Add record to the Google Sheets Lead Ledger
appendToSheet(customer);
// 2. Provision the contact into the corporate phonebook
createGoogleContact(customer);
return ContentService.createTextOutput(JSON.stringify({ status: "Success" }))
.setMimeType(ContentService.MimeType.JSON);
} catch (error) {
return ContentService.createTextOutput("Error: " + error.message).setStatusCode(500);
}
}
// Helper Function: Writing to the Google Sheet CRM
function appendToSheet(customer) {
// Make sure your sheet tab is named "Lead Pipeline"
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Lead Pipeline");
const timestamp = new Date();
sheet.appendRow([
timestamp,
customer.company_name,
customer.first_name + " " + customer.last_name,
customer.email,
customer.phone,
"New B2B Lead" // Default initial pipeline stage
]);
}
// Helper Function: Injecting into Google Contacts via People API
function createGoogleContact(customer) {
const contactResource = {
"names": [
{
"givenName": customer.first_name,
"familyName": customer.last_name
}
],
"emailAddresses": [
{
"value": customer.email,
"type": "work"
}
],
"phoneNumbers": [
{
"value": customer.phone,
"type": "workMobile"
}
],
"organizations": [
{
"name": customer.company_name,
"title": "B2B Buyer Registration"
}
]
};
// Execute the People API contact provisioning
People.People.createContact(contactResource);
}
Once the script is saved, click Deploy > New Deployment, choose Web app, and configure it to execute as "Me" and allow access to "Anyone." Copy the generated Web App URL.
Step 2: Outbound Data Dispatch from Magento 2
On your Adobe Commerce / Magento 2 instance, you need an Observer or Plugin to intercept registrations. Your module should hook into the customer_register_success event and fire a standard curl payload to your newly generated Google Web App URL:
{
"token": "MAGESHEET_B2B_CRM_SYNC_2026",
"customer_data": {
"first_name": "Sarah",
"last_name": "Lee",
"email": "sarah.lee@omni-co.test",
"company_name": "OmniCo Logistics",
"phone": "+1-555-0199"
}
}
Why This Paradigm Beats Traditional Heavy SaaS Integrations
For small-to-medium enterprises (SMEs) processing high-value corporate accounts, this native integration pattern changes the entire playbook:
Instant Caller ID & Mobility
When your sales representative opens Gmail or answers their phone on the road, they shouldn't have to look up data inside a siloed CRM dashboard to figure out who is calling. Because the People API injects the customer straight into the corporate Google Contacts directory, the contact details sync automatically to their phone. The rep instantly gets Caller ID context for the incoming wholesale lead.Zero Runtime Infrastructure & Per-User Costs
You are not spinning up AWS instances, configuring Node.js backend servers, or paying HubSpot $50–$100 per user every month. Google Apps Script scales automatically inside Google's infrastructure, running completely serverless and costing exactly $0.Infinite Custom Automation Potential
Because your database is now a clean, structured Google Sheet grid, expanding the workflow takes minutes. Want to trigger a customized introduction draft inside Gmail? Want to automate a Google Calendar discovery invite? You can wire those up natively inside the exact same Apps Script project using standard Javascript.
Conclusion
Modern web engineering is shifting away from heavy middleware vendor lock-ins. By writing smart, lightweight event listeners, you can turn platforms you already use into powerful, synchronized business machines.
The full guide with advanced data mapping configurations and production-ready enterprise structures is available on the MageSheet blog:
If you are scaling a complex Adobe Commerce B2B ecosystem and want to link it directly to your core operational environments without brittle third-party integrations, explore our automation blueprints at magesheet.com.








