DEV Community

Tugelbay Konabayev
Tugelbay Konabayev

Posted on • Originally published at about-kazakhstan.com

Detecting Keyword Cannibalization with the Search Console API

What is Keyword Cannibalization

When multiple pages on your site compete for the same search query, Google splits ranking signals between them. Neither page ranks as well as a single consolidated page would. This is keyword cannibalization.

Detection Algorithm

async function detectCannibalization(siteUrl, days = 28) {
  const res = await webmasters.searchanalytics.query({
    siteUrl,
    requestBody: {
      startDate: daysAgo(days),
      endDate: today(),
      dimensions: ["query", "page"],
      rowLimit: 5000
    }
  });

  // Group by query
  const queryMap = {};
  for (const row of res.data.rows) {
    const query = row.keys[0];
    const page = row.keys[1];
    if (!queryMap[query]) queryMap[query] = [];
    queryMap[query].push({
      page, position: row.position,
      impressions: row.impressions
    });
  }

  // Find queries with 2+ pages
  return Object.entries(queryMap)
    .filter(([_, pages]) => pages.length >= 2)
    .map(([query, pages]) => ({
      query,
      pages: pages.sort((a, b) => a.position - b.position)
    }));
}
Enter fullscreen mode Exit fullscreen mode

Resolution Strategies

  1. KEEP strongest page (best position + most impressions)
  2. MERGE content from weaker page into stronger
  3. 301 redirect weaker URL to stronger
  4. Differentiate intent if pages serve different user needs

Automated Recommendations

function recommend(cannibalizedQuery) {
  const [keep, ...merge] = cannibalizedQuery.pages;

  return {
    action: "MERGE",
    keep: keep.page,
    merge: merge.map(p => p.page),
    reason: keep.position < merge[0].position
      ? "Better position" : "More impressions"
  };
}
Enter fullscreen mode Exit fullscreen mode

Real Example

A celebrity fan page had two articles competing for the same name query. After merging content and adding a 301 redirect, the surviving page jumped 8 positions within two weeks.

Regular cannibalization checks should be part of any SEO maintenance routine.

Top comments (0)