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.

Easy Saves ~2 hours/month E-commerceBy Flowngn team

Works with n8n · Make · Zapier

How it works

Trigger: Shopify — new order
  1. Receive the new order.
  2. Check the customer's order count.
  3. On every 5th order, email them a thank-you and a VIP code.

Diagram

trueSNew orderShopify Trigger{ }Order milestone?Code⑂5th, 10th, 15th…?IfGSend thank-youGmail
Trigger App Logic Code

Code

JavaScript used in the Code step — already included in the template below.

Order milestone? · Code node
// 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.

Workflow JSON
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": []
}

Open in the playground to edit →

Tips

  • Create the VIP code in Shopify with a once-per-customer limit.

Related flows