{
  "id": "S81xOmH76K2CZTCo",
  "name": "Automate ad performance monitoring with Meta Ads, Google Ads & Email alerts",
  "tags": [],
  "nodes": [
    {
      "id": "0a99edd7-30bc-4341-8029-4c6679ad7c23",
      "name": "your-google-sheets-name",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3280,
        528
      ],
      "parameters": {
        "columns": {
          "value": {
            "CTR": "={{ $json.ctr }}",
            "Date": "={{$now.format('yyyy-MM-dd')}}",
            "ROAS": "={{ $json.roas }}",
            "Spend": "={{ $json.spend }}",
            "Clicks": "={{ $json.clicks }}",
            "Currency": "INR",
            "Platform": "={{ $json.platform }}",
            "Alert_Sent": "Yes",
            "Check_Time": "={{$now}}",
            "Drop_Reason": "={{ $json.Drop_Reason }}",
            "Impressions": "={{ $json.impressions }}",
            "Alert_Channel": "Slack,Email,whatsapp",
            "Campaign_Name": "={{ $json.campaign_name }}",
            "Performance_Status": "={{ $json.Performance_Status }}"
          },
          "schema": [
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Platform",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Platform",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Campaign_Name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Campaign_Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Impressions",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Impressions",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Clicks",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Clicks",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Spend",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Spend",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "CTR",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "CTR",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ROAS",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ROAS",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Performance_Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Performance_Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Drop_Reason",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Drop_Reason",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Currency",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Currency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Check_Time",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Check_Time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Alert_Sent",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Alert_Sent",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Alert_Channel",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Alert_Channel",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Previous_CTR",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Previous_CTR",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Previous_ROAS",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Previous_ROAS",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Notes",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Notes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Campaign_Name"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "your-google-sheets-url",
          "cachedResultName": "Ad_Performance_Log"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "your-google-sheets-document-id",
          "cachedResultUrl": "your-google-sheets-url",
          "cachedResultName": "Ads Drop Alert"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "42cd07b0-5da3-4aee-96ed-c2d33d2f90d7",
      "name": "Daily Ad Check2",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        752,
        240
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "1bc24059-097f-4d84-a5e8-b3c065463a05",
      "name": "Fetch Meta Ads Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1008,
        240
      ],
      "parameters": {
        "url": "your-facebook-graph-api-endpoint",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "fields",
              "value": "campaign_name,impressions,clicks,spend,actions,action_values"
            },
            {
              "name": "date_preset",
              "value": "yesterday"
            },
            {
              "name": "level",
              "value": "campaign"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "cfe05983-5732-4e18-9db4-55340b999ae0",
      "name": "Set Benchmarks",
      "type": "n8n-nodes-base.set",
      "position": [
        1264,
        240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "cb7b5611-c4aa-4069-8c12-7a0a601d6291",
              "name": "campaign_name",
              "type": "string",
              "value": "={{ $json.campaign_name }}"
            },
            {
              "id": "affee17f-6902-41fb-882c-bc651779b5c0",
              "name": "impressions",
              "type": "number",
              "value": "={{ $json.impressions }}"
            },
            {
              "id": "4be7ac04-910d-46e7-bdff-a684dfb7342a",
              "name": "clicks",
              "type": "number",
              "value": "={{ $json.clicks }}"
            },
            {
              "id": "953f8a82-1753-419f-8f82-4be07b81b0c6",
              "name": "spend",
              "type": "number",
              "value": "={{ $json.spend }}"
            },
            {
              "id": "0d7f60c5-fffb-4d2a-9cc1-667c4f4cb2bb",
              "name": "action_values",
              "type": "array",
              "value": "={{ $json.action_values }}"
            },
            {
              "id": "bbc75f34-7a28-400b-bb11-41a314418be7",
              "name": "actions",
              "type": "array",
              "value": "={{ $json.actions }}"
            },
            {
              "id": "0d552735-5031-45aa-9d07-7431bae1019c",
              "name": "platform",
              "type": "string",
              "value": "META"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "001c1a9a-0e28-41a2-a36a-763f5683d8b2",
      "name": "Detect Performance Drop",
      "type": "n8n-nodes-base.code",
      "position": [
        1600,
        352
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\n\n// Thresholds\nconst MIN_CTR = 2;   // %\nconst MIN_ROAS = 4; // ratio\n\nreturn items.map(({ json: item }) => {\n\n  const impressions = Number(item.impressions || 0);\n  const clicks = Number(item.clicks || 0);\n  const spend = Number(item.spend || 0);\n\n  // Current CTR\n  let ctr = 0;\n  if (impressions > 0) {\n    ctr = (clicks / impressions) * 100;\n  }\n\n  // Revenue\n  let revenue = 0;\n  if (Array.isArray(item.action_values)) {\n    const purchase = item.action_values.find(\n      a => a.action_type === 'purchase'\n    );\n    if (purchase?.value) {\n      revenue = Number(purchase.value);\n    }\n  }\n\n  // Current ROAS\n  let roas = 0;\n  if (spend > 0) {\n    roas = revenue / spend;\n  }\n\n  // Previous values (will be populated from Google Sheets lookup)\n  const previous_ctr = item.previous_ctr || null;\n  const previous_roas = item.previous_roas || null;\n\n  // Drop logic\n  let alert = false;\n  let dropReason = '';\n  let performanceStatus = 'OK';\n\n  if (ctr < MIN_CTR) {\n    alert = true;\n    performanceStatus = 'DROPPED';\n    dropReason = 'CTR below threshold';\n  }\n\n  if (roas < MIN_ROAS) {\n    alert = true;\n    performanceStatus = 'DROPPED';\n    dropReason = dropReason\n      ? dropReason + ' & ROAS below threshold'\n      : 'ROAS below threshold';\n  }\n\n  return {\n    json: {\n      ...item,\n      ctr: Number(ctr.toFixed(2)),\n      revenue: Number(revenue.toFixed(2)),\n      roas: Number(roas.toFixed(2)),\n      previous_ctr: previous_ctr,\n      previous_roas: previous_roas,\n      alert,\n      Performance_Status: performanceStatus,\n      Drop_Reason: dropReason\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "6413c650-9f45-4e5a-b840-2ba27961cd03",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        1808,
        352
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "331f7a0f-192c-4e8c-abf9-8f5194c1d9ae",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.alert }}",
              "rightValue": "true"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "290fe711-4881-4278-89bd-cf1470dba773",
      "name": "Send a message",
      "type": "n8n-nodes-base.slack",
      "position": [
        2496,
        352
      ],
      "parameters": {
        "text": "=Hello,  This is an automated performance alert from your ad monitoring system.  One of your ad campaigns has shown a significant performance drop based on today\u2019s analysis. Please review the details below:  <strong>Campaign Name:</strong> {{ $json.campaign_name }} <strong>Platform:</strong> {{ $json.platform || \"Meta Ads\" }}  <strong>Performance Metrics:</strong> \u2022 Impressions: {{ $json.impressions }} \u2022 Clicks: {{ $json.clicks }} \u2022 Spend: {{ $json.spend }} \u2022 CTR: {{ $json.ctr }}% \u2022 ROAS: {{ $json.roas }}  <strong>Status:</strong> {{ $json.Performance_Status }} <strong>Reason:</strong> {{ $json.Drop_Reason }}  We recommend reviewing targeting, creatives, bidding strategy, or budget allocation to prevent further performance loss.  This alert was generated automatically to help you take timely action and reduce wasted ad spend.  If you need assistance analyzing or optimizing this campaign, feel free to reach out.  Best regards, <strong>Ad Performance Monitoring Bot</strong> Automated via n8n",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C0A56EXB2D8",
          "cachedResultName": "all-n8ntest"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.4
    },
    {
      "id": "68e145f4-cac3-4e68-b325-e5790ac5b4c0",
      "name": "Send a message4",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2496,
        528
      ],
      "parameters": {
        "sendTo": "your email address",
        "message": "=Hello,  This is an automated performance alert from your ad monitoring system.  One of your ad campaigns has shown a significant performance drop based on today\u2019s analysis. Please review the details below:  <strong>Campaign Name:</strong> {{ $json.campaign_name }} <strong>Platform:</strong> {{ $json.platform || \"Meta Ads\" }}  <strong>Performance Metrics:</strong> \u2022 Impressions: {{ $json.impressions }} \u2022 Clicks: {{ $json.clicks }} \u2022 Spend: {{ $json.spend }} \u2022 CTR: {{ $json.ctr }}% \u2022 ROAS: {{ $json.roas }}  <strong>Status:</strong> {{ $json.Performance_Status }} <strong>Reason:</strong> {{ $json.Drop_Reason }}  We recommend reviewing targeting, creatives, bidding strategy, or budget allocation to prevent further performance loss.  This alert was generated automatically to help you take timely action and reduce wasted ad spend.  If you need assistance analyzing or optimizing this campaign, feel free to reach out.  Best regards, <strong>Ad Performance Monitoring Bot</strong> Automated via n8n",
        "options": {},
        "subject": "\ud83d\udea8 Ad Performance Alert: Immediate Attention Required"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "1ed585cf-4601-4781-959c-614a705fe671",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        2144,
        336
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "ad32c6b5-ef9f-42f3-83c8-b4cda36ccf57",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        2800,
        352
      ],
      "parameters": {
        "jsCode": "// Explicitly fetch the original data\n// from Detect Performance Drop node\n\nconst items = $items(\"Detect Performance Drop\");\n\nreturn items.map(item => ({\n  json: item.json\n}));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "9ab29847-6da0-4cf2-a49a-830f9f22fcc6",
      "name": "Set Benchmarks4",
      "type": "n8n-nodes-base.set",
      "position": [
        1264,
        448
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "cb7b5611-c4aa-4069-8c12-7a0a601d6291",
              "name": "campaign_name",
              "type": "string",
              "value": "={{ $json.campaign_name }}"
            },
            {
              "id": "affee17f-6902-41fb-882c-bc651779b5c0",
              "name": "impressions",
              "type": "number",
              "value": "={{ $json.impressions }}"
            },
            {
              "id": "4be7ac04-910d-46e7-bdff-a684dfb7342a",
              "name": "clicks",
              "type": "number",
              "value": "={{ $json.clicks }}"
            },
            {
              "id": "953f8a82-1753-419f-8f82-4be07b81b0c6",
              "name": "spend",
              "type": "number",
              "value": "={{ $json.spend }}"
            },
            {
              "id": "0d7f60c5-fffb-4d2a-9cc1-667c4f4cb2bb",
              "name": "action_values",
              "type": "array",
              "value": "={{ $json.action_values }}"
            },
            {
              "id": "bbc75f34-7a28-400b-bb11-41a314418be7",
              "name": "actions",
              "type": "array",
              "value": "={{ $json.actions }}"
            },
            {
              "id": "0d552735-5031-45aa-9d07-7431bae1019c",
              "name": "platform",
              "type": "string",
              "value": "Google"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e3b86c6c-5d41-4b4a-82b0-9c20f41cbd67",
      "name": "Get many campaigns",
      "type": "n8n-nodes-base.googleAds",
      "position": [
        1008,
        448
      ],
      "parameters": {
        "requestOptions": {},
        "additionalOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "4c53a090-c896-4d36-b199-cbd6d3128726",
      "name": "Wait1",
      "type": "n8n-nodes-base.wait",
      "position": [
        3024,
        448
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "44ae1216-8235-4ded-8142-f536285642aa",
      "name": "Daily Ad Check3",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        752,
        448
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 10,
              "triggerAtMinute": {}
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "ca70c0fa-d32a-4d64-9afa-f3afa620eb7c",
      "name": "Send message1",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        2496,
        192
      ],
      "parameters": {
        "operation": "send",
        "additionalFields": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "e926809b-791d-441e-a52a-6e005bd4f2e1",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 720,
        "height": 800,
        "content": "## Ad Performance Drop Alert Automation (Google & Meta Ads)\n\nThis workflow monitors your Google Ads and Meta Ads campaigns on a daily schedule to detect sudden performance drops and notify your team immediately. It helps prevent wasted ad spend by catching issues early, before they impact results at scale.\n\n### How it works\nThe workflow runs automatically using scheduled triggers. It pulls yesterday\u2019s campaign performance data from Meta Ads and Google Ads, including impressions, clicks, spend, and conversion values. For each campaign, it calculates key metrics such as CTR, revenue, and ROAS. These values are compared against predefined benchmarks to identify campaigns that are underperforming. When a drop is detected, the campaign is flagged with a clear performance status and drop reason. Alerts are then sent through multiple channels, and the event is logged for tracking and reporting.\n\n### Setup steps\n1. Connect your Meta Ads account and provide a valid access token.\n2. Authenticate your Google Ads account.\n3. Review and adjust CTR and ROAS thresholds in the performance detection logic.\n4. Connect Slack, Gmail, and WhatsApp for alerts.\n5. Link a Google Sheet to store alert history.\n6. Set your preferred daily schedule times.\n7. Activate the workflow.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "337289f6-547a-43c7-b29e-9e84a85f6d1f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        736,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 816,
        "height": 800,
        "content": "## Step 1: Fetch Ad Performance Data\nPulls daily campaign metrics from Meta Ads and Google Ads using scheduled triggers.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ad288dd7-eaea-4a16-b059-72564722839c",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1568,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 864,
        "height": 800,
        "content": "## Step 2: Detect Performance Drops\nCalculates CTR and ROAS and flags campaigns that fall below defined benchmarks.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "99f3e531-2a23-4c96-b361-f9d7225ede9c",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2448,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 992,
        "height": 800,
        "content": "## Step 3: Alert & Log Results\nSends alerts via Slack, Email, and WhatsApp and logs results in Google Sheets.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "beb7dbc1-f534-4abf-b6c8-6e6af9611ba5",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "your-google-sheets-name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send message1": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Benchmarks": {
      "main": [
        [
          {
            "node": "Detect Performance Drop",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Ad Check2": {
      "main": [
        [
          {
            "node": "Fetch Meta Ads Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Ad Check3": {
      "main": [
        [
          {
            "node": "Get many campaigns",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send a message4",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message4": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Benchmarks4": {
      "main": [
        [
          {
            "node": "Detect Performance Drop",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many campaigns": {
      "main": [
        [
          {
            "node": "Set Benchmarks4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Meta Ads Data": {
      "main": [
        [
          {
            "node": "Set Benchmarks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect Performance Drop": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}