This workflow corresponds to n8n.io template #5470 — we link there as the canonical source.
This workflow follows the Discord → 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": "EkiPj955iLTz4N2X",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "google analytics to discord",
"tags": [
{
"id": "ieqEVthNwLDfYSc1",
"name": "Emp0",
"createdAt": "2025-05-06T11:04:25.307Z",
"updatedAt": "2025-05-06T11:04:25.307Z"
}
],
"nodes": [
{
"id": "d3bf8c74-1adf-46ca-8bb0-18ad83a1a3e7",
"name": "Edit Fields2",
"type": "n8n-nodes-base.set",
"position": [
440,
80
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "c89a369e-0c67-476f-8227-b56b2b1c87b3",
"name": "discord_channel_id",
"type": "string",
"value": ""
},
{
"id": "0bc05648-2f31-4757-8703-75d3c7f80917",
"name": "google_analytics_id",
"type": "string",
"value": "="
}
]
}
},
"typeVersion": 3.4
},
{
"id": "6592e781-3b51-44c7-9b60-0d38cb6143b2",
"name": "Edit Fields3",
"type": "n8n-nodes-base.set",
"position": [
440,
280
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "c89a369e-0c67-476f-8227-b56b2b1c87b3",
"name": "discord_channel_id",
"type": "string",
"value": ""
},
{
"id": "be197313-7b88-462a-8ff7-9bb9ddf7e846",
"name": "google_analytics_id",
"type": "string",
"value": ""
}
]
}
},
"typeVersion": 3.4
},
{
"id": "325bcec9-276a-4a62-9755-04c3033f385f",
"name": "Google Analytics",
"type": "n8n-nodes-base.googleAnalytics",
"position": [
820,
380
],
"parameters": {
"metricsGA4": {
"metricValues": [
{},
{
"listName": "active1DayUsers"
},
{
"listName": "active7DayUsers"
},
{
"listName": "eventCount"
},
{
"listName": "screenPageViews"
},
{
"listName": "userEngagementDuration"
}
]
},
"propertyId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.google_analytics_id }}"
},
"dimensionsGA4": {
"dimensionValues": [
{}
]
},
"additionalFields": {}
},
"credentials": {
"googleAnalyticsOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2
},
{
"id": "e8b1a2da-d59f-44fb-8d03-60e6304d0d3a",
"name": "Schedule Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
280,
280
],
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 21,
"triggerAtMinute": 51
}
]
}
},
"typeVersion": 1.2
},
{
"id": "5b91ccf6-5397-4e4b-97a9-bbe196ddbc8e",
"name": "Schedule Trigger1",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
280,
80
],
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 21,
"triggerAtMinute": 50
}
]
}
},
"typeVersion": 1.2
},
{
"id": "9073f015-ae42-4461-b423-88fa2d45c205",
"name": "Sort",
"type": "n8n-nodes-base.sort",
"position": [
980,
380
],
"parameters": {
"options": {},
"sortFieldsUi": {
"sortField": [
{
"fieldName": "date"
}
]
}
},
"typeVersion": 1
},
{
"id": "a71e1cdd-ddc3-458d-b349-638ad0d59146",
"name": "Discord",
"type": "n8n-nodes-base.discord",
"position": [
1280,
380
],
"parameters": {
"limit": 10,
"guildId": {
"__rl": true,
"mode": "list",
"value": "1363068664886329397"
},
"options": {},
"resource": "message",
"channelId": {
"__rl": true,
"mode": "id",
"value": "={{ $('Code1').first().json.discord_channel_id }}"
},
"operation": "getAll",
"authentication": "oAuth2"
},
"credentials": {
"discordOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 2,
"alwaysOutputData": true
},
{
"id": "67074924-8e24-4cf2-bc0b-115112b1bcef",
"name": "Code",
"type": "n8n-nodes-base.code",
"position": [
1620,
380
],
"parameters": {
"jsCode": "// n8n Function Node\n\n// 1. Grab GA records\nconst gaRecords = $('gaData').first().json.gaData;\nconst discord_channel_id = $('Code1').first().json.discord_channel_id;\n\n// 2. Grab Discord messages and unpack their .json\nconst discordMsgs = $input.all().map(item => item.json);\n\n// Helper: get embed field by name\nfunction getEmbedField(msg, name) {\n return msg.embeds?.[0]?.fields.find(f => f.name === name)?.value || null;\n}\n\n// Format JS Date to dd-MM-yyyy\nfunction formatDate(dateObj) {\n const dd = String(dateObj.getDate()).padStart(2,'0');\n const mm = String(dateObj.getMonth()+1).padStart(2,'0');\n const yyyy = dateObj.getFullYear();\n return `${dd}-${mm}-${yyyy}`;\n}\n\nconst today = formatDate(new Date());\n\n// Build lookup of Discord messages by Date\nconst discordByDate = {};\nfor (const msg of discordMsgs) {\n const date = getEmbedField(msg, 'Date');\n if (date) discordByDate[date] = msg;\n}\n\nconst results = [];\n\nfor (const wrapper of gaRecords) {\n const rec = wrapper.json;\n const dateKey = rec.date;\n const existing = discordByDate[dateKey];\n\n // Prepare new fields\n const newFields = [\n { name: 'Date', value: rec.date, inline: true },\n { name: 'totalUsers', value: rec.totalUsers, inline: true },\n { name: 'active1DayUsers', value: rec.active1DayUsers, inline: true },\n { name: 'active7DayUsers', value: rec.active7DayUsers, inline: true },\n { name: 'eventCount', value: rec.eventCount, inline: true },\n { name: 'screenPageViews', value: rec.screenPageViews, inline: true },\n { name: 'userEngagementDuration', value: rec.userEngagementDuration, inline: true },\n { name: 'createdAt', value: existing ? getEmbedField(existing, 'createdAt') : today, inline: true },\n { name: 'updatedAt', value: today, inline: true },\n ];\n\n // If exists, compare fields to avoid unnecessary updates\n if (existing) {\n let changed = false;\n for (const field of newFields) {\n if (getEmbedField(existing, field.name) !== field.value) {\n changed = true;\n break;\n }\n }\n if (changed) {\n results.push({\n action: 'update',\n messageId: existing.id,\n channelId: discord_channel_id,\n payload: {\n content: '',\n embeds: [{\n type: 'rich',\n color: 16751872,\n fields: newFields,\n footer: {\n text: 'Google Analytics',\n icon_url: 'https://images-ext-1.discordapp.net/external/BO599wb-y-yg7GM59J_ZSexsGRd2zIqOF98eJ89J_04/https/www.gstatic.com/analytics-suite/header/suite/v2/ic_analytics.svg'\n }\n }]\n }\n });\n }\n } else {\n // New record \u2192 create\n results.push({\n action: 'create',\n channelId: discord_channel_id,\n payload: {\n content: '',\n embeds: [{\n type: 'rich',\n color: 16751872,\n fields: newFields,\n footer: {\n text: 'Google Analytics',\n icon_url: 'https://images-ext-1.discordapp.net/external/BO599wb-y-yg7GM59J_ZSexsGRd2zIqOF98eJ89J_04/https/www.gstatic.com/analytics-suite/header/suite/v2/ic_analytics.svg'\n }\n }]\n }\n });\n }\n}\n\n// Return array for next nodes\nreturn results.map(r => ({ json: r }));\n"
},
"typeVersion": 2
},
{
"id": "01594d3d-7bc9-425c-af39-27c69d825321",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-40,
40
],
"parameters": {
"width": 640,
"height": 180,
"content": "## Google Analytics Property 1\n## Discord Channel 1\n"
},
"typeVersion": 1
},
{
"id": "04ed2530-fa65-427f-9019-bf970055481c",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-40,
240
],
"parameters": {
"width": 640,
"height": 180,
"content": "## Google Analytics Property 2\n## Discord Channel 2\n"
},
"typeVersion": 1
},
{
"id": "7567b2b8-2c12-42d8-898a-be7f59414061",
"name": "Code1",
"type": "n8n-nodes-base.code",
"position": [
680,
380
],
"parameters": {
"jsCode": "return $input.all();"
},
"typeVersion": 2
},
{
"id": "84d96e4a-2da5-4823-ba06-ec56346c5247",
"name": "gaData",
"type": "n8n-nodes-base.code",
"position": [
1120,
380
],
"parameters": {
"jsCode": "return {\"gaData\":$input.all()}"
},
"typeVersion": 2
},
{
"id": "6ea881a9-19ef-4f4c-815c-efd5b963a7fc",
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"position": [
2380,
200
],
"parameters": {
"url": "=https://discord.com/api/v10/channels/{{ $json.channelId }}/messages",
"method": "POST",
"options": {},
"jsonBody": "={{ $json.payload }}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
},
"typeVersion": 4.2
},
{
"id": "e27342c6-4128-4be3-bf95-1d11fdc36126",
"name": "HTTP Request8",
"type": "n8n-nodes-base.httpRequest",
"position": [
2340,
620
],
"parameters": {
"url": "=https://discord.com/api/v10/channels/{{ $json.channelId }}/messages/{{ $json.messageId }}",
"method": "PATCH",
"options": {},
"jsonBody": "={{ $json.payload }}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
},
"typeVersion": 4.2
},
{
"id": "113d9181-b7f5-455c-8c98-3592b223544a",
"name": "Switch",
"type": "n8n-nodes-base.switch",
"position": [
1840,
380
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "create",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "0fada883-e01d-402f-a582-960511303d1f",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.action }}",
"rightValue": "create"
}
]
},
"renameOutput": true
},
{
"outputKey": "update",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "28274b49-c3eb-49cc-9e22-ee10e0be456f",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.action }}",
"rightValue": "update"
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "e1bb4d90-07d8-4d9a-9fa9-77969b980973",
"name": "Loop Over Items",
"type": "n8n-nodes-base.splitInBatches",
"position": [
2140,
600
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "cb148176-64d2-412d-b93f-7a4f41f71bb6",
"name": "Wait",
"type": "n8n-nodes-base.wait",
"position": [
2560,
620
],
"parameters": {
"amount": 10
},
"typeVersion": 1.1
},
{
"id": "32daa189-fbf3-456f-8fe1-532ea5329163",
"name": "Loop Over Items4",
"type": "n8n-nodes-base.splitInBatches",
"position": [
2140,
160
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "acfea1dc-6154-419a-bfc3-33d38b88d392",
"name": "Wait4",
"type": "n8n-nodes-base.wait",
"position": [
2560,
180
],
"parameters": {
"amount": 10
},
"typeVersion": 1.1
},
{
"id": "d2aebef9-605a-471a-b0cd-c90946e0ecaf",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
2060,
20
],
"parameters": {
"color": 5,
"width": 700,
"height": 360,
"content": "## send a new discord message\n\nif its a new day, then we send a new discord message to the discord server with the latest google analytics data. Google analytics data refreshes at UTC midnight"
},
"typeVersion": 1
},
{
"id": "530cb064-a232-4791-8041-d2e86d081687",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
2060,
440
],
"parameters": {
"color": 5,
"width": 700,
"height": 400,
"content": "## update an existing discord message\n\nGoogle analytics data in not real time and the value changes in the next few days. After 7 days, the traffic values are finalized. So in order to display the accurate traffic to the discord server, we need to update the previous values "
},
"typeVersion": 1
},
{
"id": "04c66040-d5dd-46df-874c-13a2f41e5bee",
"name": "Edit Fields",
"type": "n8n-nodes-base.set",
"position": [
440,
480
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "c89a369e-0c67-476f-8227-b56b2b1c87b3",
"name": "discord_channel_id",
"type": "string",
"value": ""
},
{
"id": "0bc05648-2f31-4757-8703-75d3c7f80917",
"name": "google_analytics_id",
"type": "string",
"value": "="
}
]
}
},
"typeVersion": 3.4
},
{
"id": "41409245-e194-4e69-866c-f357af2607b1",
"name": "Edit Fields4",
"type": "n8n-nodes-base.set",
"position": [
440,
680
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "c89a369e-0c67-476f-8227-b56b2b1c87b3",
"name": "discord_channel_id",
"type": "string",
"value": ""
},
{
"id": "be197313-7b88-462a-8ff7-9bb9ddf7e846",
"name": "google_analytics_id",
"type": "string",
"value": ""
}
]
}
},
"typeVersion": 3.4
},
{
"id": "15404bc5-657a-4429-ada9-6528d766b779",
"name": "Schedule Trigger2",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
280,
680
],
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 21,
"triggerAtMinute": 53
}
]
}
},
"typeVersion": 1.2
},
{
"id": "1901a316-6baa-4674-b8b5-cfa4a35d3818",
"name": "Schedule Trigger3",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
280,
480
],
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 21,
"triggerAtMinute": 52
}
]
}
},
"typeVersion": 1.2
},
{
"id": "34d1a765-f42a-4cdd-bc7a-2c97234fd3fd",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-40,
440
],
"parameters": {
"width": 640,
"height": 180,
"content": "## Google Analytics Property 3\n## Discord Channel 3\n\n"
},
"typeVersion": 1
},
{
"id": "44ca144f-ca2d-4c7a-8348-2a50dbb48772",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-40,
640
],
"parameters": {
"width": 640,
"height": 180,
"content": "## Google Analytics Property 4\n## Discord Channel 4\n"
},
"typeVersion": 1
},
{
"id": "28e662c6-7071-4d54-b7ca-710d185e3422",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
820,
200
],
"parameters": {
"color": 7,
"width": 400,
"content": "### Fetches and sorts google analytics data\n\nEnsure that your google analytics data is setup properly, follow the [n8n guide here](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googleanalytics/)"
},
"typeVersion": 1
},
{
"id": "dfc3412f-e989-4c6f-aa8e-5a2e34b0221d",
"name": "Sticky Note7",
"type": "n8n-nodes-base.stickyNote",
"position": [
1280,
200
],
"parameters": {
"color": 7,
"width": 260,
"content": "### Fetches and sorts discord messages from the channel\n\nEnsure that your discord Oauth is setup properly, follow the [n8n guide to setup discord oauth](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.discord/)"
},
"typeVersion": 1
},
{
"id": "1287b658-275e-4d72-858c-2f279a20eb41",
"name": "Sort6",
"type": "n8n-nodes-base.sort",
"onError": "continueRegularOutput",
"position": [
1440,
380
],
"parameters": {
"options": {},
"sortFieldsUi": {
"sortField": [
{
"fieldName": "embeds[0].fields[0].value"
}
]
}
},
"typeVersion": 1
},
{
"id": "8a999078-a716-4b1a-b501-dec5beb469f0",
"name": "Sticky Note8",
"type": "n8n-nodes-base.stickyNote",
"position": [
1600,
200
],
"parameters": {
"color": 7,
"width": 160,
"content": "### Maps the data\nusing the Date field"
},
"typeVersion": 1
},
{
"id": "dfe339cd-0335-4f77-8517-a35441eb6193",
"name": "Sticky Note9",
"type": "n8n-nodes-base.stickyNote",
"position": [
2060,
-140
],
"parameters": {
"color": 7,
"width": 700,
"height": 120,
"content": "### Use the discord api to update messages\nHere, we use the official discord api rather than the discord node to update messages because that feature has not been implmented in n8n yet. [Read the official discord docs](https://discord.com/developers/docs/reference#authentication) to setup your Bot Token Authorization Header"
},
"typeVersion": 1
},
{
"id": "39be50dc-79bc-4091-a802-ae7aacdfa684",
"name": "Sticky Note10",
"type": "n8n-nodes-base.stickyNote",
"position": [
-580,
-20
],
"parameters": {
"color": 7,
"width": 440,
"height": 480,
"content": "## Get your discord channel id\n1. Get your discord channel id by sending a text on your discord channel and then copy message link\n2. Paste the text below and you will see your message link in the form of https://discord.com/channels/server_id/channel_id/message_id , you will want to get the channel_id which is the number in the middle\n"
},
"typeVersion": 1
},
{
"id": "a1032930-f62f-49d4-8e39-28c9c73fe5a2",
"name": "Sticky Note11",
"type": "n8n-nodes-base.stickyNote",
"position": [
-580,
500
],
"parameters": {
"color": 7,
"width": 440,
"height": 420,
"content": "## Get your google analytics id\n1. Find your google analytics id by going to google analytics dashboard, seeing the properties in the top right and copy paste that number to the flow\n"
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"callerPolicy": "workflowsFromSameOwner",
"errorWorkflow": "ernonQOxi07n6WGi",
"executionOrder": "v1"
},
"versionId": "064d13a2-ee8a-4672-9065-09e4aed21c32",
"connections": {
"Code": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Sort": {
"main": [
[
{
"node": "gaData",
"type": "main",
"index": 0
}
]
]
},
"Wait": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Code1": {
"main": [
[
{
"node": "Google Analytics",
"type": "main",
"index": 0
}
]
]
},
"Sort6": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Wait4": {
"main": [
[
{
"node": "Loop Over Items4",
"type": "main",
"index": 0
}
]
]
},
"Switch": {
"main": [
[
{
"node": "Loop Over Items4",
"type": "main",
"index": 0
}
],
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"gaData": {
"main": [
[
{
"node": "Discord",
"type": "main",
"index": 0
}
]
]
},
"Discord": {
"main": [
[
{
"node": "Sort6",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields2": {
"main": [
[
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields3": {
"main": [
[
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields4": {
"main": [
[
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request": {
"main": [
[
{
"node": "Wait4",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request8": {
"main": [
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[],
[
{
"node": "HTTP Request8",
"type": "main",
"index": 0
}
]
]
},
"Google Analytics": {
"main": [
[
{
"node": "Sort",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items4": {
"main": [
[],
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Edit Fields3",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger1": {
"main": [
[
{
"node": "Edit Fields2",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger2": {
"main": [
[
{
"node": "Edit Fields4",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger3": {
"main": [
[
{
"node": "Edit Fields",
"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.
discordOAuth2ApigoogleAnalyticsOAuth2httpHeaderAuth
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Fetch Multiple Google Analytics GA4 metrics daily, post to Discord, update previous day’s entry as GA data finalizes over seven days. Automates daily traffic reporting Maintains single message per day, avoids channel clutter Provides near–real-time updates by editing prior…
Source: https://n8n.io/workflows/5470/ — 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.
This workflow runs on scheduled weekly and monthly triggers to generate unified marketing performance reports. It processes multiple websites by collecting analytics data, paid ads performance, and CR
Google analytics template. Uses scheduleTrigger, manualTrigger, stickyNote, googleAnalytics. Scheduled trigger; 22 nodes.
If you own a website and need to analyze your Google analytics data If you need to create an SEO report on which pages are getting most traffic or how your google search terms are performing If you wa
This workflow is designed for marketing teams, data analysts, and business owners who need to consistently track key performance indicators (KPIs). It saves hours of manual data collection and reporti
Workflow A — WhatsApp Lead Intake & Qualification. Uses postgres, httpRequest, errorTrigger. Scheduled trigger; 67 nodes.