{
  "name": "Monthly email: pages that rank in Google but not in Bing, and the other way round (GSC Magic)",
  "nodes": [
    {
      "id": "c06ff6c8-5f49-4386-a3da-a99ec45b041b",
      "name": "2nd of every month at 08:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "months",
              "triggerAtDayOfMonth": 2,
              "triggerAtHour": 8
            }
          ]
        }
      }
    },
    {
      "id": "63f063b0-879d-4167-aa2e-d00124fe850f",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        308,
        0
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b3ec14b3-771a-424e-a6ca-aa61b73a6cd2",
              "name": "site",
              "value": "example.com",
              "type": "string"
            },
            {
              "id": "189aedce-b1f0-4e14-a525-1e8afc21a875",
              "name": "bingSiteUrl",
              "value": "https://example.com/",
              "type": "string"
            },
            {
              "id": "d1c19760-b1f1-4307-a0b0-2a50e2f9ff36",
              "name": "minGoogleClicks",
              "value": 20,
              "type": "number"
            },
            {
              "id": "deda5fb3-cb79-43b8-a5eb-cfffc5bb7af7",
              "name": "recipientEmail",
              "value": "you@example.com",
              "type": "string"
            },
            {
              "id": "4741b06c-2724-4cfb-a5cb-41516c4dcde0",
              "name": "senderEmail",
              "value": "reports@example.com",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "57976596-baf6-41b9-af39-3fc55e60f3e4",
      "name": "GSC Magic: Google and Bing per page",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        616,
        0
      ],
      "onError": "continueRegularOutput",
      "parameters": {
        "method": "POST",
        "url": "https://mcp.gscmagic.com/mcp",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json, text/event-stream"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'report_google_vs_bing', arguments: { site: $json.site, bing_site_url: $json.bingSiteUrl, range: 'last_28_days', limit: 500 } } }) }}",
        "options": {
          "batching": {
            "batch": {
              "batchSize": 1,
              "batchInterval": 300
            }
          },
          "timeout": 180000
        }
      }
    },
    {
      "id": "d634a0fe-91eb-417e-a3b2-50bb5f35e45b",
      "name": "Find the gaps",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        924,
        0
      ],
      "parameters": {
        "jsCode": "// Turns a GSC Magic response (MCP JSON-RPC) into { ok, data, error, image }.\nfunction unwrap(res) {\n  const result = res && res.result;\n  if (result && Array.isArray(result.content)) {\n    const text = result.content.filter((b) => b.type === 'text').map((b) => b.text).join('\\n');\n    if (result.isError) return { ok: false, error: text || 'GSC Magic reported an error' };\n    let data;\n    try { data = JSON.parse(text); } catch (e) { data = { text }; }\n    const image = result.content.find((b) => b.type === 'image' && b.data);\n    return { ok: true, data, image };\n  }\n  const err = res && res.error;\n  const message = typeof err === 'string' ? err : (err && (err.message || err.description)) || 'No response from GSC Magic';\n  if (/401|unauthori[sz]ed|Authorization failed/i.test(message)) {\n    return { ok: false, error: 'GSC Magic rejected the access token (wrong, expired or revoked). Create a new one in the GSC Magic dashboard: Connect > Access tokens.' };\n  }\n  return { ok: false, error: String(message) };\n}\n\n// ---- email kit: layout and components (inline styles, works in Gmail, Outlook, Apple Mail) ----\nconst K = { ink: '#111827', muted: '#6b7280', faint: '#9ca3af', line: '#e5e7eb', bg: '#f3f4f6', soft: '#f9fafb',\n  good: '#166534', goodBg: '#dcfce7', bad: '#b91c1c', badBg: '#fee2e2', warn: '#92400e', warnBg: '#fef3c7', info: '#1e40af', infoBg: '#dbeafe' };\nconst FONT = \"-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif\";\nconst esc = (s) => String(s ?? '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\"/g, '&quot;');\nconst fmt = (n) => (n === null || n === undefined || Number.isNaN(Number(n)) ? '-' : Number(n).toLocaleString('en-US'));\nconst urlPath = (u) => String(u).replace(/^https?:\\/\\/[^/]+/i, '') || '/';\nconst short = (s, n) => (String(s).length > n ? String(s).slice(0, n - 1) + '...' : String(s));\nfunction pill(text, tone) {\n  const c = { good: [K.good, K.goodBg], bad: [K.bad, K.badBg], warn: [K.warn, K.warnBg], info: [K.info, K.infoBg] }[tone] || [K.muted, K.bg];\n  return '<span style=\"display:inline-block;padding:2px 8px;border-radius:999px;background:' + c[1] + ';color:' + c[0] + ';font-size:12px;font-weight:700;line-height:18px;white-space:nowrap;\">' + esc(text) + '</span>';\n}\nfunction change(now, before, goodWhenUp = true) {\n  if (!before) return now ? pill('new', 'info') : '';\n  const d = Math.round(((now - before) / before) * 100);\n  if (d === 0) return pill('0%', 'neutral');\n  return pill((d > 0 ? '+' : '') + d + '%', (d > 0) === goodWhenUp ? 'good' : 'bad');\n}\nfunction link(url, text, accent) {\n  return '<a href=\"' + esc(url) + '\" style=\"color:' + accent + ';text-decoration:none;font-weight:600;\">' + esc(text) + '</a>';\n}\nfunction kpis(items) {\n  const w = Math.floor(100 / items.length);\n  return '<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse:separate;border-spacing:8px 0;margin:4px -8px 0;\"><tr>'\n    + items.map((k) => '<td width=\"' + w + '%\" valign=\"top\" style=\"background:' + K.soft + ';border:1px solid ' + K.line + ';border-radius:10px;padding:14px 12px;\">'\n      + '<div style=\"font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:' + K.muted + ';font-weight:700;\">' + esc(k.label) + '</div>'\n      + '<div style=\"font-size:22px;font-weight:800;margin:4px 0 6px;color:' + K.ink + ';\">' + esc(k.value) + '</div>'\n      + '<div style=\"min-height:20px;\">' + (k.badge || '') + '</div></td>').join('')\n    + '</tr></table>';\n}\nfunction section(title, body, note) {\n  return '<div style=\"margin:30px 0 0;\"><div style=\"font-size:17px;font-weight:800;color:' + K.ink + ';margin:0 0 4px;\">' + esc(title) + '</div>'\n    + (note ? '<div style=\"font-size:13px;color:' + K.muted + ';margin:0 0 12px;\">' + note + '</div>' : '<div style=\"height:8px\"></div>') + body + '</div>';\n}\nfunction table(cols, rows) {\n  const th = cols.map((c) => '<td align=\"' + (c.align || 'left') + '\" style=\"padding:8px 10px;font-size:11px;letter-spacing:.05em;text-transform:uppercase;color:' + K.muted + ';font-weight:700;border-bottom:1px solid ' + K.line + ';\">' + esc(c.label) + '</td>').join('');\n  const tr = rows.map((r) => '<tr>' + r.map((cell, i) => '<td align=\"' + (cols[i].align || 'left') + '\" valign=\"top\" style=\"padding:10px;font-size:14px;border-bottom:1px solid ' + K.line + ';\">' + cell + '</td>').join('') + '</tr>').join('');\n  return '<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse:collapse;\"><tr>' + th + '</tr>' + tr + '</table>';\n}\nfunction bar(share, accent) {\n  const p = Math.max(2, Math.min(100, Math.round(share * 100)));\n  return '<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse:collapse;\"><tr>'\n    + '<td width=\"' + p + '%\" style=\"background:' + accent + ';height:6px;line-height:6px;font-size:0;border-radius:3px;\">&nbsp;</td>'\n    + (p < 100 ? '<td style=\"background:' + K.line + ';height:6px;line-height:6px;font-size:0;border-radius:3px;\">&nbsp;</td>' : '') + '</tr></table>';\n}\nfunction callout(html, tone) {\n  const c = { good: [K.good, K.goodBg], bad: [K.bad, K.badBg], warn: [K.warn, K.warnBg] }[tone] || [K.info, K.infoBg];\n  return '<div style=\"background:' + c[1] + ';border-left:4px solid ' + c[0] + ';border-radius:8px;padding:14px 16px;margin:18px 0 0;font-size:14px;color:' + K.ink + ';\">' + html + '</div>';\n}\nfunction bullets(items) {\n  return '<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse:collapse;\">' + items.map((t) => '<tr><td valign=\"top\" style=\"padding:3px 8px 3px 0;color:' + K.muted + ';\">&#9679;</td><td style=\"padding:3px 0;font-size:14px;\">' + t + '</td></tr>').join('') + '</table>';\n}\nfunction numbered(items) {\n  return '<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse:collapse;\">' + items.map((t, i) => '<tr><td valign=\"top\" style=\"padding:4px 10px 4px 0;\"><span style=\"display:inline-block;width:22px;height:22px;line-height:22px;border-radius:11px;background:' + K.bg + ';color:' + K.ink + ';font-size:12px;font-weight:800;text-align:center;\">' + (i + 1) + '</span></td><td style=\"padding:5px 0;font-size:14px;\">' + t + '</td></tr>').join('') + '</table>';\n}\nfunction emailLayout(o) {\n  const a = o.accent || '#2563eb';\n  return '<!doctype html><html><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><meta name=\"color-scheme\" content=\"light\"></head>'\n    + '<body style=\"margin:0;padding:0;background:' + K.bg + ';\">'\n    + '<div style=\"display:none;max-height:0;overflow:hidden;opacity:0;\">' + esc(o.preheader || '') + '</div>'\n    + '<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background:' + K.bg + ';\"><tr><td align=\"center\" style=\"padding:28px 12px;\">'\n    + '<table role=\"presentation\" width=\"600\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:100%;max-width:600px;background:#ffffff;border:1px solid ' + K.line + ';border-radius:14px;font-family:' + FONT + ';color:' + K.ink + ';\">'\n    + '<tr><td style=\"background:' + a + ';height:6px;line-height:6px;font-size:0;border-radius:14px 14px 0 0;\">&nbsp;</td></tr>'\n    + '<tr><td style=\"padding:26px 28px 6px;\">'\n    + '<div style=\"font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:' + a + ';font-weight:800;\">' + esc(o.eyebrow || '') + '</div>'\n    + '<div style=\"font-size:24px;line-height:1.25;font-weight:800;margin:6px 0 4px;\">' + esc(o.title) + '</div>'\n    + (o.subtitle ? '<div style=\"font-size:14px;color:' + K.muted + ';\">' + esc(o.subtitle) + '</div>' : '')\n    + '</td></tr>'\n    + '<tr><td style=\"padding:10px 28px 28px;font-size:15px;line-height:1.55;\">' + o.body + '</td></tr>'\n    + '<tr><td style=\"padding:16px 28px 20px;border-top:1px solid ' + K.line + ';font-size:12px;line-height:1.5;color:' + K.muted + ';\">' + (o.footer || '') + '</td></tr>'\n    + '</table></td></tr></table></body></html>';\n}\n// ---- end of email kit ----\n\nconst cfg = $('Settings').first().json;\nconst accent = '#0f766e';\nconst res = unwrap($input.first().json);\nconst site = String(cfg.site).replace(/^sc-domain:/, '');\nif (!res.ok) {\n  return [{ json: { subject: 'Google vs Bing report failed for ' + site, html: emailLayout({\n    accent, eyebrow: 'Google vs Bing', title: 'Report failed', subtitle: site,\n    preheader: 'GSC Magic could not build the Google vs Bing report',\n    body: callout('<b>GSC Magic could not build the report.</b><br>' + esc(res.error), 'bad')\n      + section('Usual causes', bullets(['No Bing Webmaster Tools API key under Sources in the GSC Magic dashboard.', '<b>bingSiteUrl</b> in Settings does not match the site in Bing Webmaster Tools exactly.', 'The GSC Magic token was revoked or expired.'])),\n    footer: 'Sent by your n8n workflow.' }) } }];\n}\n\nconst rows = res.data.rows || [];\nconst t = res.data.totals || { google_clicks: 0, bing_clicks: 0 };\nconst all = t.google_clicks + t.bing_clicks;\nconst avgShare = all ? t.bing_clicks / all : 0;\nconst big = rows.filter((r) => r.google_clicks >= cfg.minGoogleClicks);\nconst missing = big.filter((r) => r.bing_impressions === 0).sort((a, b) => b.google_clicks - a.google_clicks);\nconst weak = big.filter((r) => r.bing_impressions > 0 && avgShare > 0 && r.bing_share_of_clicks < avgShare / 2).sort((a, b) => b.google_clicks - a.google_clicks);\nconst better = rows.filter((r) => r.bing_clicks >= 5 && r.bing_clicks > r.google_clicks).sort((a, b) => b.bing_clicks - a.bing_clicks);\n\nconst cols = [{ label: 'Page' }, { label: 'Google', align: 'right' }, { label: 'Bing', align: 'right' }, { label: 'Bing impr.', align: 'right' }];\nconst list = (title, note, tone, items) => !items.length ? '' : section(title + ' (' + items.length + ')',\n  table(cols, items.slice(0, 15).map((r) => [link(r.url, short(urlPath(r.url), 40), accent), fmt(r.google_clicks), pill(fmt(r.bing_clicks), tone), fmt(r.bing_impressions)]))\n  + (items.length > 15 ? '<div style=\"color:' + K.muted + ';font-size:13px;margin-top:6px;\">and ' + (items.length - 15) + ' more</div>' : ''), note);\n\nconst html = emailLayout({\n  accent, eyebrow: 'Google vs Bing', title: site, subtitle: 'Clicks per page, last 28 days',\n  preheader: missing.length + ' pages with Google traffic get no Bing impressions. Bing share of clicks: ' + Math.round(avgShare * 100) + '%.',\n  body: kpis([\n    { label: 'Google clicks', value: fmt(t.google_clicks), badge: pill('28 days', 'neutral') },\n    { label: 'Bing clicks', value: fmt(t.bing_clicks), badge: pill('28 days', 'neutral') },\n    { label: 'Bing share', value: Math.round(avgShare * 100) + '%', badge: pill('of all clicks', 'info') },\n    { label: 'Missing in Bing', value: fmt(missing.length), badge: missing.length ? pill('to check', 'warn') : pill('none', 'good') },\n  ])\n    + list('Missing in Bing', 'Real Google traffic, zero Bing impressions. Check the URL in Bing Webmaster Tools (URL Inspection) and submit it with IndexNow.', 'bad', missing)\n    + list('Weak in Bing', 'Bing share under half of the site average. Compare the title and content with what ranks in Bing for the same topic.', 'warn', weak)\n    + list('Better in Bing than in Google', 'Bing sends more clicks than Google. Check these pages in Search Console for indexing or ranking problems.', 'good', better)\n    + (missing.length + weak.length + better.length === 0 ? callout('No gaps above the thresholds this month.', 'good') : ''),\n  footer: 'Pages under ' + fmt(cfg.minGoogleClicks) + ' Google clicks are ignored. Bing reports weekly data, so totals near the edges of the 28 days are approximate.'\n    + (res.data.truncated ? ' Search Console returned a truncated page list, so some pages may be missing.' : '') + ' Data: Google Search Console and Bing Webmaster Tools, through GSC Magic.',\n});\n\nreturn [{ json: { subject: 'Google vs Bing: ' + missing.length + (missing.length === 1 ? ' page' : ' pages') + ' missing in Bing (' + site + ')', html } }];\n"
      }
    },
    {
      "id": "562ea341-6725-4038-ac0c-2382289635a1",
      "name": "Send the report",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        1232,
        0
      ],
      "parameters": {
        "fromEmail": "={{ $('Settings').first().json.senderEmail }}",
        "toEmail": "={{ $('Settings').first().json.recipientEmail }}",
        "subject": "={{ $json.subject }}",
        "emailFormat": "html",
        "html": "={{ $json.html }}",
        "options": {
          "appendAttribution": false
        }
      }
    },
    {
      "id": "7edbd534-615a-42a5-a0ba-c9ef02e5a7e2",
      "name": "Step 1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        -249
      ],
      "parameters": {
        "content": "## Step 1: Configure\n- **site**: Search Console property or domain.\n- **bingSiteUrl**: the site exactly as Bing Webmaster Tools lists it, usually `https://example.com/`.\n- **minGoogleClicks**: pages with fewer Google clicks in 28 days are ignored (too little data).\n- **recipientEmail / senderEmail**: who gets the report and who sends it.",
        "width": 488,
        "height": 439,
        "color": 7
      }
    },
    {
      "id": "e235fd01-e2cc-47d7-a3ba-0a1222325bc6",
      "name": "Step 2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        576,
        -249
      ],
      "parameters": {
        "content": "## Step 2: Compare Google and Bing\nClicks per page from both engines for 28 days, then three lists: missing in Bing, weak in Bing, better in Bing.",
        "width": 488,
        "height": 439,
        "color": 7
      }
    },
    {
      "id": "bb0e8f86-1a6f-466a-aab6-d463b0b2e719",
      "name": "Step 3",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1142,
        -249
      ],
      "parameters": {
        "content": "## Step 3: Email the report\nOne HTML email. If GSC Magic fails, the email says why.",
        "width": 280,
        "height": 439,
        "color": 7
      }
    },
    {
      "id": "1ec632db-5b3a-4890-adc4-8e4721e4baaf",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -740,
        -249
      ],
      "parameters": {
        "content": "## Monthly Google vs Bing page gaps\nBing's index also feeds Copilot, DuckDuckGo and Yahoo, yet most teams never open Bing Webmaster Tools. Once a month this workflow puts Google Search Console and Bing clicks for every page side by side and emails three short lists:\n- **Missing in Bing**: pages with real Google traffic and zero Bing impressions (often not indexed in Bing).\n- **Weak in Bing**: Bing's share of clicks far below the site average.\n- **Better in Bing**: pages Bing likes more than Google, worth a look on the Google side.\n\n**Who it is for:** agencies and B2B sites that want the second search engine covered without a monthly manual export.\n\n**Requirements:** the site verified in Bing Webmaster Tools and a Bing API key added in the GSC Magic dashboard under Sources.\n\n**Connect GSC Magic** (about 2 minutes)\n1. In the [GSC Magic dashboard](https://app.gscmagic.com) open **Connect > Access tokens** and create a token. Copy the `gsm_...` value (shown once).\n2. Open the first node whose name starts with **GSC Magic:**, and under **Credential for Bearer Auth** create a new credential. Paste the token into **Bearer Token**. In every other **GSC Magic:** node, select that same credential.\n3. Never paste the token into a URL, a prompt or a Code node.\n\n**Then**\n4. Fill in **Settings**, add an SMTP credential to **Send the report** (or swap in Gmail / Outlook).\n5. Execute once, check the email, activate.\n\nSchedule times use the workflow time zone (Workflow settings > Timezone), which defaults to the instance time zone.\n\n**Calls per run:** 1. Works on the Free plan.\n\n### Errors and limits\n- If GSC Magic fails (no Bing key, wrong bingSiteUrl, token), you still get an email with the reason.\n- Pages are matched by URL, ignoring protocol, `www.`, letter case, query strings and a trailing slash. Redirects between different URLs are not followed.",
        "width": 640,
        "height": 804
      }
    }
  ],
  "connections": {
    "2nd of every month at 08:00": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "GSC Magic: Google and Bing per page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GSC Magic: Google and Bing per page": {
      "main": [
        [
          {
            "node": "Find the gaps",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find the gaps": {
      "main": [
        [
          {
            "node": "Send the report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "active": false
}
