This workflow corresponds to n8n.io template #12870 — we link there as the canonical source.
This workflow follows the Google Sheets → HTTP Request recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "54iIibqDGmVybLNO",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "(Retail) Auto-Segment Customers by Purchase Behavior",
"tags": [],
"nodes": [
{
"id": "44391a41-186b-4128-b2e4-2a02e08e9818",
"name": "Normalize Customer Purchase Data",
"type": "n8n-nodes-base.set",
"position": [
-96,
-16
],
"parameters": {
"fields": {
"values": [
{
"name": "customer_id",
"stringValue": "={{ $json.body.customer.customer_id }}"
},
{
"name": "email",
"stringValue": "={{ $json.body.customer.email }}"
},
{
"name": "first_name",
"stringValue": "={{ $json.body.customer.first_name }}"
},
{
"name": "last_name",
"stringValue": "={{ $json.body.customer.last_name }}"
},
{
"name": "order_id",
"stringValue": "={{ $json.body.order.order_id }}"
},
{
"name": "order_value",
"type": "numberValue",
"numberValue": "={{ $json.body.order.order_value }}"
},
{
"name": "order_date",
"stringValue": "={{ $json.body.order.order_date }}"
},
{
"name": "order_count",
"type": "numberValue",
"numberValue": "={{ $json.body.customer_stats.order_count }}"
},
{
"name": "lifetime_spend",
"type": "numberValue",
"numberValue": "={{ $json.body.customer_stats.lifetime_spend }}"
},
{
"name": "last_order_date",
"stringValue": "={{ $json.body.customer_stats.last_order_date }}"
},
{
"name": "product_categories",
"type": "arrayValue",
"arrayValue": "={{ $json.body.order.product_categories }}"
},
{
"name": "source_system",
"stringValue": "={{ $json.body.source }}"
},
{
"name": "event_type",
"stringValue": "={{ $json.body.event_type }}"
}
]
},
"options": {}
},
"typeVersion": 3
},
{
"id": "a3ea830c-4b56-4726-9e0c-e118c28d6b3f",
"name": "Sync Customer Segment to CRM",
"type": "n8n-nodes-base.httpRequest",
"position": [
1376,
-32
],
"parameters": {
"method": "POST",
"options": {
"response": {
"response": {
"fullResponse": true
}
}
},
"jsonBody": "={\n \"customer_id\": \"{{ $json.customer_id }}\",\n \"email\": \"{{ $json.email }}\",\n \"tags\": \"{{ $json.segment_tag }}\",\n \"source\": \"{{ $json.source }}\"\n}\n",
"sendBody": true,
"specifyBody": "json"
},
"typeVersion": 4.3
},
{
"id": "71b3a234-7a27-453b-943f-d29e70e49800",
"name": "Append or update row in sheet",
"type": "n8n-nodes-base.googleSheets",
"position": [
1632,
-32
],
"parameters": {
"columns": {
"value": {
"Email": "={{ $('Normalize Customer Segment Output').item.json.email }}",
"Source": "={{ $('Normalize Customer Segment Output').item.json.source }}",
"Event Time": "={{ $('Normalize Customer Segment Output').item.json.event_time }}",
"Customer Id": "={{ $('Normalize Customer Segment Output').item.json.customer_id }}",
"Segment Tag": "={{ $('Normalize Customer Segment Output').item.json.segment_tag }}"
},
"schema": [
{
"id": "Customer Id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Customer Id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Email",
"type": "string",
"display": true,
"required": false,
"displayName": "Email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Segment Tag",
"type": "string",
"display": true,
"required": false,
"displayName": "Segment Tag",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Event Time",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Event Time",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Source",
"type": "string",
"display": true,
"required": false,
"displayName": "Source",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"Event Time"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1vPSuaAEv77tzbPLWzFM-t5iDVca9_DJBDS2rh6m5N6s/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1vPSuaAEv77tzbPLWzFM-t5iDVca9_DJBDS2rh6m5N6s",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1vPSuaAEv77tzbPLWzFM-t5iDVca9_DJBDS2rh6m5N6s/edit?usp=drivesdk",
"cachedResultName": "Log Customer Segmentation Event"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 4.7
},
{
"id": "d7d4da49-28fa-458e-922a-69f3bee77ff5",
"name": "Assign New Customer Segment",
"type": "n8n-nodes-base.set",
"position": [
720,
-144
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "938658d0-4f99-4634-b42e-fa81da052613",
"name": "segment_tag",
"type": "string",
"value": "new_customer"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "269be1fa-39db-42cc-91b6-c28dc7990947",
"name": "Assign Repeat Customer Segment",
"type": "n8n-nodes-base.set",
"position": [
720,
112
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "0098f21c-60de-46fb-85d9-69f562189878",
"name": "segment_tag",
"type": "string",
"value": "repeat_customer"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "bee2914d-5d44-44a3-9145-3957ad1dd1dd",
"name": "Normalize Customer Segment Output",
"type": "n8n-nodes-base.set",
"position": [
1152,
-32
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "b0728fba-d4f5-4160-9bc4-7d14c340cd94",
"name": "customer_id",
"type": "string",
"value": "={{ $('Normalize Customer Purchase Data').item.json.customer_id }}"
},
{
"id": "5b2b99c8-fb9f-420e-abf2-144cd5c93318",
"name": "email",
"type": "string",
"value": "={{ $('Normalize Customer Purchase Data').item.json.email }}"
},
{
"id": "9db6bc04-e73b-44ad-b70a-84de5d5cb0b0",
"name": "segment_tag",
"type": "string",
"value": "={{ $json.segment_tag }}"
},
{
"id": "8b95a433-c1b0-49f4-9989-b35494fa5321",
"name": "source",
"type": "string",
"value": "={{ $('Normalize Customer Purchase Data').item.json.source_system }}"
},
{
"id": "b014e6f4-d06b-4ab4-adbb-4146b9dc6365",
"name": "event_time",
"type": "string",
"value": "={{ $now }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "1c544388-652a-4498-aef2-f159c8981fa3",
"name": "Validate Customer Event",
"type": "n8n-nodes-base.if",
"position": [
112,
-16
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "ac00783c-e9a6-44da-9555-68bb372567ef",
"operator": {
"type": "number",
"operation": "notEquals"
},
"leftValue": "={{ $json.body.customer_stats.order_count }}",
"rightValue": 0
}
]
}
},
"typeVersion": 2.2
},
{
"id": "35c6ce52-2db8-44fe-ac25-e34d74e68398",
"name": "Determine Customer Segment",
"type": "n8n-nodes-base.switch",
"position": [
368,
-64
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "vip_customer",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "e47d3c47-0769-4422-b001-2ec47fcaed82",
"operator": {
"type": "number",
"operation": "gt"
},
"leftValue": "={{ $('Normalize Customer Purchase Data').item.json.lifetime_spend }}",
"rightValue": 1000
}
]
},
"renameOutput": true
},
{
"outputKey": "new_customer",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "da058c5a-ea27-43a2-8f42-918e391cf61b",
"operator": {
"type": "number",
"operation": "equals"
},
"leftValue": "={{ $('Normalize Customer Purchase Data').item.json.order_count }}",
"rightValue": 1
}
]
},
"renameOutput": true
},
{
"outputKey": "repeat_customer",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "44ef115c-87b7-4c98-94ab-50883fa3ef07",
"operator": {
"type": "number",
"operation": "gt"
},
"leftValue": "={{ $('Normalize Customer Purchase Data').item.json.order_count }}",
"rightValue": 1
}
]
},
"renameOutput": true
},
{
"outputKey": "inactive_customer",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "df1b1cca-b5b8-4bd3-9ff7-6a38d45d6063",
"operator": {
"type": "number",
"operation": "lt"
},
"leftValue": "={{ new Date($json.last_order_date).getTime() }}",
"rightValue": "={{ Date.now() - (60 * 24 * 60 * 60 * 1000) }}"
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.3
},
{
"id": "2f0f267b-8590-4c30-809e-d2f3189d3b5d",
"name": "Assign VIP Customer Segment",
"type": "n8n-nodes-base.set",
"position": [
720,
-336
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "2089c3db-b02d-41ca-8b71-672f489d840e",
"name": "segment_tag",
"type": "string",
"value": "vip_customer"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "13b72072-cfd3-4cb8-8709-8848318a7a8a",
"name": "Assign Inactive Customer Segment",
"type": "n8n-nodes-base.set",
"position": [
720,
256
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "1444cd7b-0ecc-4929-a88f-b263fa1bbb37",
"name": "segment_tag",
"type": "string",
"value": "inactive_customer"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "7fe02f08-f487-4bb3-ae86-5145a884052d",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1136,
-288
],
"parameters": {
"width": 672,
"height": 528,
"content": "## (Retail) Auto-Segment Customers by Purchase Behavior (Overview)\n\n### How it works\nThis workflow listens for customer or order events from platforms like WooCommerce, Shopify, or a CRM using a webhook. Incoming payloads are first normalized to extract customer and behavioral data such as order count, lifetime spend, last order date, product categories and source system.\n\nBased on these values, the workflow evaluates customer behavior using rule-based conditions. Customers are automatically classified into meaningful segments such as new customers, repeat customers, VIP customers, or inactive customers. Once a segment is assigned, the workflow prepares a clean output and syncs the segment tag to a CRM or email platform. Each segmentation event is also logged into Google Sheets for tracking and auditing.\n\n### Setup steps\n1. Configure your source system to send customer or order events to the webhook.\n2. Ensure required fields like order count, lifetime spend, last order date and source are included in the payload.\n3. Update the CRM HTTP Request node with your actual API endpoint and authentication.\n4. Connect Google Sheets and ensure required columns exist.\n5. Test with sample payloads and activate the workflow.\n"
},
"typeVersion": 1
},
{
"id": "5612b1c3-30aa-42e2-8032-af8a6699ed13",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-400,
-272
],
"parameters": {
"color": 7,
"width": 672,
"height": 512,
"content": "## Event Intake & Data Normalization\n\nThis section receives customer or order events via webhook and converts raw payloads into a consistent structure. Key attributes like customer ID, email, order count, lifetime spend, last order date and source system are standardized here for reliable downstream processing."
},
"typeVersion": 1
},
{
"id": "cb027141-e08a-4b3f-a40e-0bbeac941991",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
336,
-576
],
"parameters": {
"color": 7,
"width": 736,
"height": 1024,
"content": "## Customer Segmentation Rules\n\nThis section determines which segment a customer belongs to using rule-based logic. Customers are classified as VIP, new, repeat, or inactive based on purchase frequency, lifetime spend and last activity date. Each branch assigns a clear segment tag for downstream syncing.\n"
},
"typeVersion": 1
},
{
"id": "d490b0f6-1391-4b97-9be0-5ce04469c1d5",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1104,
-288
],
"parameters": {
"color": 7,
"width": 736,
"height": 544,
"content": "## Sync Segment & Log Activity\n\nAfter a segment is assigned, the workflow prepares a clean output payload. Customer segment tags are synced to a CRM or email platform and each segmentation event is logged in Google Sheets for visibility, reporting and audit purposes.\n"
},
"typeVersion": 1
},
{
"id": "f9e7f43e-8e29-4f1d-8734-6755906a83a1",
"name": "Receive Customer Order or Update Event",
"type": "n8n-nodes-base.webhook",
"position": [
-336,
-16
],
"parameters": {
"path": "customer-segmentation",
"options": {},
"httpMethod": "POST"
},
"typeVersion": 2
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "f863ba0c-9434-474e-977c-c5348037b8ce",
"connections": {
"Validate Customer Event": {
"main": [
[
{
"node": "Determine Customer Segment",
"type": "main",
"index": 0
}
],
[]
]
},
"Determine Customer Segment": {
"main": [
[
{
"node": "Assign VIP Customer Segment",
"type": "main",
"index": 0
}
],
[
{
"node": "Assign New Customer Segment",
"type": "main",
"index": 0
}
],
[
{
"node": "Assign Repeat Customer Segment",
"type": "main",
"index": 0
}
],
[
{
"node": "Assign Inactive Customer Segment",
"type": "main",
"index": 0
}
]
]
},
"Assign New Customer Segment": {
"main": [
[
{
"node": "Normalize Customer Segment Output",
"type": "main",
"index": 0
}
]
]
},
"Assign VIP Customer Segment": {
"main": [
[
{
"node": "Normalize Customer Segment Output",
"type": "main",
"index": 0
}
]
]
},
"Sync Customer Segment to CRM": {
"main": [
[
{
"node": "Append or update row in sheet",
"type": "main",
"index": 0
}
]
]
},
"Assign Repeat Customer Segment": {
"main": [
[
{
"node": "Normalize Customer Segment Output",
"type": "main",
"index": 0
}
]
]
},
"Assign Inactive Customer Segment": {
"main": [
[
{
"node": "Normalize Customer Segment Output",
"type": "main",
"index": 0
}
]
]
},
"Normalize Customer Purchase Data": {
"main": [
[
{
"node": "Validate Customer Event",
"type": "main",
"index": 0
}
]
]
},
"Normalize Customer Segment Output": {
"main": [
[
{
"node": "Sync Customer Segment to CRM",
"type": "main",
"index": 0
}
]
]
},
"Receive Customer Order or Update Event": {
"main": [
[
{
"node": "Normalize Customer Purchase Data",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
googleSheetsOAuth2Api
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow automatically segments customers based on their purchase behavior whenever a new order or customer update event is received from platforms like WooCommerce, Shopify, or a CRM. It classifies customers into meaningful segments such as new customers, repeat customers,…
Source: https://n8n.io/workflows/12870/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
[SANTOBET] FLUXO TODO - BACKUP. Uses googleSheets, httpRequest, googleSheetsTrigger. Webhook trigger; 57 nodes.
FLUXO DISPARO DATA E HORA. Uses itemLists, googleSheets, httpRequest. Webhook trigger; 48 nodes.
This workflow allows you to accept online payments via YooKassa and log both orders and transactions in Google Sheets — all without writing a single line of code. It supports full payment flow: produc
Transform your n8n instance management with this advanced automation system featuring artificial intelligence-driven workflow selection. This template provides comprehensive maintenance operations wit
Nexus_v6(ล่าสุดจริงๆ)ล่าสุดไกไก. Uses googleSheets, httpRequest. Webhook trigger; 41 nodes.