8
n8n 中文网amn8n.com

Matomo分析报告

中级

这是一个Marketing领域的自动化工作流,包含 10 个节点。主要使用 Code, Baserow, HttpRequest, ManualTrigger, ScheduleTrigger 等节点。 将Matomo分析数据发送给AI分析,然后将结果保存到Baserow

前置要求
  • 可能需要目标 API 的认证凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "PRQhetYFkuhxntVH",
  "meta": {
    "instanceId": "558d88703fb65b2d0e44613bc35916258b0f0bf983c5d4730c00c424b77ca36a",
    "templateCredsSetupCompleted": true
  },
  "name": "Matomo 分析报告",
  "tags": [],
  "nodes": [
    {
      "id": "fd35d612-09a6-4dd3-836b-53d03b75f344",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        120,
        360
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c8169606-3abd-4dd3-bd35-fdc0296fc0e1",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        120,
        160
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "760a87e3-ed8f-4b1e-a46b-4ceb635020d4",
      "name": "从 Matomo 获取数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        380,
        260
      ],
      "parameters": {
        "url": "https://shrewd-lyrebird.pikapod.net/index.php",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "name": "module",
              "value": "API"
            },
            {
              "name": "method",
              "value": "Live.getLastVisitsDetails"
            },
            {
              "name": "idSite",
              "value": "3"
            },
            {
              "name": "period",
              "value": "range"
            },
            {
              "name": "date",
              "value": "last30"
            },
            {
              "name": "format",
              "value": "JSON"
            },
            {
              "name": "segment",
              "value": "visitCount>3"
            },
            {
              "name": "filter_limit",
              "value": "100"
            },
            {
              "name": "showColumns",
              "value": "actionDetails,visitIp,visitorId,visitCount"
            },
            {
              "name": "token_auth",
              "value": "{insert your auth token}"
            }
          ]
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "f9e9a099-3131-4320-8a86-b9add4e43096",
      "name": "解析 Matomo 数据",
      "type": "n8n-nodes-base.code",
      "position": [
        580,
        260
      ],
      "parameters": {
        "jsCode": "// Get input data\nconst items = $input.all();\n\n// Format the visitor data into a clear prompt\nconst visitorData = items.map(item => {\n  const visit = item.json;\n  \n  const visitorActions = visit.actionDetails.map(action => \n    `  - Page ${action.pageviewPosition}: ${action.pageTitle}\\n    URL: ${action.url}\\n    Time Spent: ${action.timeSpentPretty}`\n  ).join('\\n');\n\n  return `- Visitor (ID: ${visit.visitorId}):\\n  Visit Count: ${visit.visitCount}\\n${visitorActions}`;\n}).join('\\n\\n');\n\n// Create the prompt\nconst prompt = `Please analyze this visitor data:\\n\\n${visitorData}\\n\\nPlease provide insights on:\\n1. Common visitor paths\\n2. Popular pages\\n3. User engagement patterns\\n4. Recommendations for improvement`;\n\n// Return formatted for LLaMA\nreturn [{\n  json: {\n    messages: [\n      {\n        role: \"user\",\n        content: prompt\n      }\n    ]\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "387832ee-8397-43f8-bf62-846e4a7a20d0",
      "name": "发送数据到 AI 进行分析",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        760,
        260
      ],
      "parameters": {
        "url": "https://openrouter.ai/api/v1/chat/completions",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"model\": \"meta-llama/llama-3.1-70b-instruct:free\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"You are an SEO expert. This is data of visitors who have visited my site more then 3 times and the pages they have visited. Can you give me insights into this data:{{ encodeURIComponent($json.messages[0].content)}}\" \n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "WY7UkF14ksPKq3S8",
          "name": "Header Auth account 2"
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "7ee29949-550e-4f3a-8420-49ca2608bbeb",
      "name": "将结果存储在 Baserow 中",
      "type": "n8n-nodes-base.baserow",
      "position": [
        1060,
        260
      ],
      "parameters": {
        "tableId": 643,
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": 6261,
              "fieldValue": "={{ DateTime.now().toFormat('yyyy-MM-dd') }}"
            },
            {
              "fieldId": 6262,
              "fieldValue": "={{ $json.choices[0].message.content }}"
            },
            {
              "fieldId": 6263,
              "fieldValue": "Your blog name"
            }
          ]
        },
        "operation": "create",
        "databaseId": 121
      },
      "credentials": {
        "baserowApi": {
          "id": "8w0zXhycIfCAgja3",
          "name": "Baserow account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "684ca1c9-97c3-4464-8ce6-aa6019db0c04",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -360
      ],
      "parameters": {
        "color": 5,
        "width": 615,
        "height": 289,
        "content": "## 将 Matomo 分析发送给 AI 并将结果保存到 baserow"
      },
      "typeVersion": 1
    },
    {
      "id": "29723224-416e-46b4-a498-90888eb9a41b",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        -20
      ],
      "parameters": {
        "width": 224.51612903225822,
        "height": 461.4193548387107,
        "content": "## 获取 Matomo 数据"
      },
      "typeVersion": 1
    },
    {
      "id": "c694c855-c37a-4717-befd-d7a216f99e2d",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        700,
        -20
      ],
      "parameters": {
        "color": 3,
        "width": 225.99936321742769,
        "height": 508.95792207792226,
        "content": "## 发送数据到 AI"
      },
      "typeVersion": 1
    },
    {
      "id": "fdd12783-0456-4fc7-8030-555f058f2fd2",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        960,
        -20
      ],
      "parameters": {
        "color": 6,
        "width": 331.32883116883124,
        "height": 474.88,
        "content": "## 发送数据到 Baserow"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "21a1d486-5bb8-40b9-9032-6ab22d8baebc",
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get data from Matomo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get data from Matomo": {
      "main": [
        [
          {
            "node": "Parse data from Matomo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse data from Matomo": {
      "main": [
        [
          {
            "node": "Send data to A.I. for analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send data to A.I. for analysis": {
      "main": [
        [
          {
            "node": "Store results in Baserow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Get data from Matomo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 营销

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量10
分类1
节点类型6
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Keith Rumjahn

Keith Rumjahn

@rumjahn

I create automations with A.I. for SEO content and other smart automations.

外部链接
在 n8n.io 查看

分享此工作流