{"id":"PRQhetYFkuhxntVH","meta":{"instanceId":"workflow-e4e2a90e","versionId":"1.0.0","createdAt":"2025-09-29T07:07:43.462977","updatedAt":"2025-09-29T07:07:43.462997","owner":"n8n-user","license":"MIT","category":"automation","status":"active","priority":"high","environment":"production"},"name":"Matomo Analytics Report","nodes":[{"id":"fd35d612-09a6-4dd3-836b-53d03b75f344","name":"When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","position":[120,360],"parameters":{},"typeVersion":1,"notes":"This manualTrigger node performs automated tasks as part of the workflow."},{"id":"c8169606-3abd-4dd3-bd35-fdc0296fc0e1","name":"Schedule Trigger","type":"n8n-nodes-base.scheduleTrigger","position":[120,160],"parameters":{"rule":{"interval":[{"field":"weeks"}]}},"typeVersion":1.2,"notes":"This scheduleTrigger node performs automated tasks as part of the workflow."},{"id":"760a87e3-ed8f-4b1e-a46b-4ceb635020d4","name":"Get data from Matomo","type":"n8n-nodes-base.httpRequest","position":[380,260],"parameters":{"url":"{{ $env.WEBHOOK_URL }}","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,"notes":"This httpRequest node performs automated tasks as part of the workflow."},{"id":"f9e9a099-3131-4320-8a86-b9add4e43096","name":"Parse data from 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,"notes":"This code node performs automated tasks as part of the workflow."},{"id":"387832ee-8397-43f8-bf62-846e4a7a20d0","name":"Send data to A.I. for analysis","type":"n8n-nodes-base.httpRequest","position":[760,260],"parameters":{"url":"{{ $env.API_BASE_URL }}","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":"{{ $credentials.genericCredentialType }}","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"WY7UkF14ksPKq3S8","name":"Header Auth account 2"}},"typeVersion":4.2,"alwaysOutputData":false,"notes":"This httpRequest node performs automated tasks as part of the workflow."},{"id":"7ee29949-550e-4f3a-8420-49ca2608bbeb","name":"Store results in 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,"notes":"This baserow node performs automated tasks as part of the workflow."},{"id":"684ca1c9-97c3-4464-8ce6-aa6019db0c04","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[80,-360],"parameters":{"color":5,"width":615,"height":289,"content":"## Send Matomo analytics to A.I. and save results to baserow\n\nThis workflow will check for visitors who have visited more than 3 times. It will take this week's data and compare it to last week's data and give SEO suggestions.\n\n[Watch youtube tutorial here]({{ $env.WEBHOOK_URL }}\n\n[Get my SEO A.I. agent system here]({{ $env.WEBHOOK_URL }}\n\n[💡 You can read more about this workflow here]({{ $env.WEBHOOK_URL }}\n"},"typeVersion":1,"notes":"This stickyNote node performs automated tasks as part of the workflow."},{"id":"29723224-416e-46b4-a498-90888eb9a41b","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[320,-20],"parameters":{"width":224.51612903225822,"height":461.4193548387107,"content":"## Get Matomo Data\n \n1. Enter your Matomo API key at the bottom\n2. Navigate to Administration > Personal > Security > Auth tokens within your Matomo dashboard. Click on Create new token and provide a purpose for reference."},"typeVersion":1,"notes":"This stickyNote node performs automated tasks as part of the workflow."},{"id":"c694c855-c37a-4717-befd-d7a216f99e2d","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[700,-20],"parameters":{"color":3,"width":225.99936321742769,"height":508.95792207792226,"content":"## Send data to A.I.\n\nFill in your Openrouter A.I. credentials. Use Header Auth.\n- Username: Authorization\n- Password: Bearer {insert your API key}\n\nRemember to add a space after bearer. Also, feel free to modify the prompt to A.1."},"typeVersion":1,"notes":"This stickyNote node performs automated tasks as part of the workflow."},{"id":"fdd12783-0456-4fc7-8030-555f058f2fd2","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[960,-20],"parameters":{"color":6,"width":331.32883116883124,"height":474.88,"content":"## Send data to Baserow\n\nCreate a table first with the following columns:\n- Date\n- Note\n- Blog\n\nEnter the name of your website under \"Blog\" field."},"typeVersion":1,"notes":"This stickyNote node performs automated tasks as part of the workflow."}],"active":false,"settings":{"executionOrder":"v1","saveManualExecutions":true,"callerPolicy":"workflowsFromSameOwner","errorWorkflow":null,"timezone":"UTC","executionTimeout":3600,"maxExecutions":1000,"retryOnFail":true,"retryCount":3,"retryDelay":1000},"versionId":"21a1d486-5bb8-40b9-9032-6ab22d8baebc","connections":{"Get data from Matomo":{"main":[[],[],[],[],[],[],[],[],[]]},"Send data to A.I. for analysis":{"main":[[],[],[],[],[],[],[],[],[]]}},"description":"Automated workflow: Matomo Analytics Report. This workflow integrates 7 different services: stickyNote, httpRequest, code, scheduleTrigger, stopAndError. It contains 14 nodes and follows best practices for error handling and security.","notes":"Excellent quality workflow: Matomo Analytics Report. This workflow has been optimized for production use with comprehensive error handling, security, and documentation."}