Thank loyal Shopify customers on every 5th order
On a customer's 5th, 10th, 15th order, send a personal thank-you email with a VIP discount code.
How it works
Trigger: Shopify — new order
- Receive the new order.
- Check the customer's order count.
- On every 5th order, email them a thank-you and a VIP code.
Diagram
Trigger App Logic Code
Code
JavaScript used in the Code step — already included in the template below.
// Mode: Run Once for Each Item
// Shopify order → is this the customer's 5th, 10th, 15th… order?
const c = $json.customer || {};
const count = Number(c.orders_count) || 0;
return {
json: {
vip: count >= 5 && count % 5 === 0,
count,
email: c.email || $json.email || "",
name: c.first_name || "",
order: $json.name,
},
};Build it
Pick your tool — same automation, step by step.
Copy and paste straight into an n8n canvas (Ctrl+V), or download and use Import from File. Then connect your own credentials and replace every YOUR_… placeholder.
Show code (143 lines)
{
"name": "Thank loyal Shopify customers on every 5th order (Flowngn)",
"nodes": [
{
"parameters": {
"content": "## Thank loyal Shopify customers on every 5th order\nOn a customer's 5th, 10th, 15th order, send a personal thank-you email with a VIP discount code.\n\n**Setup**\n1. Open each node and connect your own credentials.\n2. Replace every YOUR_… placeholder.\n3. Test once, then activate.\n\nFree template from Flowngn",
"height": 260,
"width": 340
},
"id": "458210f1-f980-4989-a1ec-07858e8eaece",
"name": "Setup notes",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-420,
-60
]
},
{
"parameters": {
"topic": "orders/create"
},
"id": "458210f1-f980-4989-a1ec-07858e8eaece",
"name": "New order",
"type": "n8n-nodes-base.shopifyTrigger",
"typeVersion": 1,
"position": [
0,
0
],
"webhookId": "458210f1-f980-4989-a1ec-07858e8eaece"
},
{
"parameters": {
"jsCode": "// Mode: Run Once for Each Item\n// Shopify order → is this the customer's 5th, 10th, 15th… order?\nconst c = $json.customer || {};\nconst count = Number(c.orders_count) || 0;\n\nreturn {\n json: {\n vip: count >= 5 && count % 5 === 0,\n count,\n email: c.email || $json.email || \"\",\n name: c.first_name || \"\",\n order: $json.name,\n },\n};",
"mode": "runOnceForEachItem"
},
"id": "458210f1-f980-4989-a1ec-07858e8eaece",
"name": "Order milestone?",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
300,
0
]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "loose"
},
"conditions": [
{
"id": "c1",
"leftValue": "={{ $json.vip && $json.email !== '' }}",
"rightValue": "",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "458210f1-f980-4989-a1ec-07858e8eaece",
"name": "5th, 10th, 15th…?",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
600,
0
]
},
{
"parameters": {
"sendTo": "={{ $json.email }}",
"subject": "=Thank you for order #{{ $json.count }}, {{ $json.name || 'friend' }} 💛",
"emailType": "text",
"message": "=Hi {{ $json.name || 'there' }},\n\nThis is your {{ $json.count }}th order with us, and we wanted to say a real thank you.\n\nHere's a code for 15% off your next order: YOUR_VIP_CODE\n\nWith love,\nYOUR_NAME at YOUR_STORE",
"options": {
"appendAttribution": false
}
},
"id": "458210f1-f980-4989-a1ec-07858e8eaece",
"name": "Send thank-you",
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
900,
0
]
}
],
"connections": {
"New order": {
"main": [
[
{
"node": "Order milestone?",
"type": "main",
"index": 0
}
]
]
},
"Order milestone?": {
"main": [
[
{
"node": "5th, 10th, 15th…?",
"type": "main",
"index": 0
}
]
]
},
"5th, 10th, 15th…?": {
"main": [
[
{
"node": "Send thank-you",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"meta": {
"templateCredsSetupCompleted": false
},
"tags": []
}In Make, create a new scenario and add these modules in order:
- Shopify › Watch Orders
- Tools › Set variable / Iterator + Array aggregator (same logic as the Code step)
- Filter on the next route: “5th, 10th, 15th…?”
- If yesGmail › Send an Email
- Every module run uses Make operations — the free plan includes a monthly quota.
- Make's built-in functions (map, sum, formatDate…) can replace most Code steps; for complex logic use a code module.
- Module and step names can differ slightly as Make and Zapier update their apps.
In Zapier, create a new Zap and add these steps in order:
- Shopify — New Order
- Code by Zapier — Run JavaScript (paste the code from the Code section)
- Filter by Zapier: “5th, 10th, 15th…?”
- If yesGmail — Send Email
- Zaps with more than two steps need a paid Zapier plan.
- Webhooks, Filters/Paths and Code by Zapier are premium features on some Zapier plans.
- Code by Zapier runs JavaScript: reuse the code shown above, reading inputs from inputData instead of $json.
- Module and step names can differ slightly as Make and Zapier update their apps.
Tips
- Create the VIP code in Shopify with a once-per-customer limit.
Related flows
E-commerceMedium
Daily Shopify sales summary on WhatsApp
Every morning, get yesterday's order count and revenue sent to your WhatsApp.
Shopify → WhatsApp3h/mo
E-commerceEasy
Log every new order in Google Sheets
Each new Shopify order becomes a row in a spreadsheet you can filter and share.
Shopify → Google Sheets4h/mo
E-commerceMedium
Low-stock alert in Slack
Check inventory daily and warn your team before a product sells out.
Shopify → Slack3h/mo