Agent Wranglers

SEO-78Avoid

Taking over the back button

Adding history entries or catching the back button, so visitors who press back stay on your site or land on a page they never visited.

How to do it

Google added back button hijacking to its spam policies on 13 April 2026 and has enforced it since 15 June 2026. Pages that do it can get a manual action or rank lower. It covers code that calls history.pushState or history.replaceState on load without any action from the visitor. It also covers code that catches popstate to show an ad, an offer or a page of recommendations. Ad scripts and third-party libraries often add it without the owner knowing, and Google still holds the site responsible. A new history entry when someone opens a tab or sets a filter is fine, as Keep screen state in the address says. One press of back must always return to the page the visitor came from.

Examples

JavaScript example

import { test, expect } from '@playwright/test'

const SCRIPTS_SETTLE_MS = 10_000

test('one press of back leaves the site', async ({ page }) => {
  await page.goto('about:blank')
  await page.goto('https://example.com/pricing')
  const entriesAtLoad = await page.evaluate(() => history.length)
  await page.waitForTimeout(SCRIPTS_SETTLE_MS)
  expect(await page.evaluate(() => history.length)).toBe(entriesAtLoad)
  await page.goBack()
  expect(page.url()).toBe('about:blank')
})

Python example

from playwright.sync_api import sync_playwright

SCRIPTS_SETTLE_MS = 10_000

with sync_playwright() as p:
    page = p.chromium.launch().new_page()
    page.goto("about:blank")
    page.goto("https://example.com/pricing")
    entries_at_load = page.evaluate("history.length")
    page.wait_for_timeout(SCRIPTS_SETTLE_MS)
    assert page.evaluate("history.length") == entries_at_load
    page.go_back()
    assert page.url == "about:blank"

How to check

A browser test opens each page template from a blank page, with ads and scripts on. It waits 10 seconds and finds history.length unchanged since load. One press of back then lands on the blank page.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/seo/search-spam-and-penalties/back-button-hijacking">Agent Wranglers SEO playbook</a>. In code you write, add a comment next to it with the same link.