{
  "name": "[Template] FlowTrigger Location tracker",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "location",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "9d129f6c-501e-454b-8253-b2d7a4c8f909",
      "name": "Receive Location Data",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        960,
        432
      ],
      "webhookId": "template-geofence-webhook"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "<__PLACEHOLDER_VALUE__Google Sheets Document ID__>",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "<__PLACEHOLDER_VALUE__Sheet Tab Name__>",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "dateTime": "={{ $json.body.dateTime }}",
            "latitude": "={{ $json.body.latitude }}",
            "longitude": "={{ $json.body.longitude }}",
            "accuracyMeters": "={{ $json.body.accuracyMeters }}",
            "transition": "={{ $json.body.transition }}",
            "deviceName": "={{ $json.body.deviceName }}",
            "zoneName": "={{ $json.body.zoneName }}",
            "zoneLat": "={{ $json.body.zoneLat }}",
            "zoneLng": "={{ $json.body.zoneLng }}",
            "zoneRadiusMeters": "={{ $json.body.zoneRadiusMeters }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "dateTime",
              "displayName": "dateTime",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "latitude",
              "displayName": "latitude",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "longitude",
              "displayName": "longitude",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "accuracyMeters",
              "displayName": "accuracyMeters",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "transition",
              "displayName": "transition",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "deviceName",
              "displayName": "deviceName",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "zoneName",
              "displayName": "zoneName",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "zoneLat",
              "displayName": "zoneLat",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "zoneLng",
              "displayName": "zoneLng",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "zoneRadiusMeters",
              "displayName": "zoneRadiusMeters",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "id": "3cf2efd8-7b40-42ec-ae14-ea59040c2fb5",
      "name": "Save to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1488,
        432
      ],
      "retryOnFail": true,
      "waitBetweenTries": 2000,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ status: \"ok\", saved: true, device: $('Receive Location Data').item.json.body.deviceName, zone: $('Receive Location Data').item.json.body.zoneName, transition: $('Receive Location Data').item.json.body.transition }) }}",
        "options": {
          "responseCode": 200
        }
      },
      "id": "7687f046-467f-4e08-a74e-ebb6b94a6cb4",
      "name": "Respond OK",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        2048,
        384
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ status: \"error\", message: ($json.error ? ($json.error.message || JSON.stringify($json.error)) : \"Saving to Google Sheets failed.\") }) }}",
        "options": {
          "responseCode": 400
        }
      },
      "id": "f542b5d6-9fe6-45ff-be68-07893fd7598c",
      "name": "Respond Error",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        2048,
        560
      ]
    },
    {
      "parameters": {
        "content": "## 📍 Family Location Tracker with FlowTrigger\n\nAutomatically logs geofence events (arrivals & departures) from your family's phones using the [FlowTrigger](https://flowtrigger.app) app saves them to a Google Sheet and display on an interactive web map.\n\nYou can read the complete guide at [location tracking use case](https://flowtrigger.app/use-cases/location-tracking).\n\n---\n\n### Setup\n\n**1. Connect your spreadsheet**\n- Copy the Google Sheets Template -> [Copy](https://docs.google.com/spreadsheets/d/1o4iNjqFedzYz4iJ45cLZMvwlcO02ScKuZkewolDlzoE/copy)\n- Open `Google Sheets` node :\n   - Connect Google Sheets OAuth2 account\n   - Select the copied spreadsheet → select the **LocationHistory** sheet\n\n\n**2. Get the Webhook URL**\nPublish this workflow → open the `Receive Location Data` node → copy the **Production URL**\n\n\n**3. Set up FlowTrigger**\n- Install [FlowTrigger](https://play.google.com/store/apps/details?id=app.flowtrigger) on each family member's Android phone\n- Create a **Geofence Trigger**\n- Paste the Webhook URL\n- Define how you want to track location - distance based or zones\n- Done! Location events are now tracked automatically 🎉\n\n---\n\n### How it works\n1. A family member enters or leaves a defined zone → FlowTrigger detects the geofence transition and sends the data to this workflow\n2. The workflow saves the event (timestamp, coordinates, device, zone info) to Google Sheets\n3. View the location history in https://flowtrigger.app/map\n\n\nFor more details visit [flowtrigger.app](https://flowtrigger.app)",
        "height": 1080,
        "width": 512
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        -96
      ],
      "typeVersion": 1,
      "id": "0396e2e4-a0d8-4525-834c-038d0d6c5656",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "### Step 1: Receive Geofence Event\nNo configuration needed.",
        "height": 496,
        "width": 336,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        208
      ],
      "typeVersion": 1,
      "id": "c2a041fb-dc64-4161-b33c-a8ae177b2c71",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "### Step 2: Save to Google Sheet\n⚙️ Add **Google Sheets OAuth2** credential and select your spreadsheet\n⚙️ Add Sheet ID and Sheet name (LocationHistory)",
        "height": 496,
        "width": 480,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1312,
        208
      ],
      "typeVersion": 1,
      "id": "8f9cb4c9-c2f0-4143-9a6e-1d8f9ffa36cb",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "### Step 3: Response\nReturns success or error to FlowTrigger app.",
        "height": 496,
        "width": 400,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1888,
        208
      ],
      "typeVersion": 1,
      "id": "b114a2be-ee6a-4957-a887-3b8784d0c5c4",
      "name": "Sticky Note3"
    }
  ],
  "pinData": {},
  "connections": {
    "Receive Location Data": {
      "main": [
        [
          {
            "node": "Save to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Google Sheets": {
      "main": [
        [
          {
            "node": "Respond OK",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "versionId": "2d06183c-cadf-4320-b78f-9026df5d0b40",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "9ff1816e41534aeef40950b5f08aa9012da174683ffab0ec046294b4752686a4"
  },
  "nodeGroups": [],
  "id": "lkUvpenexLI4Go7f",
  "tags": []
}