---
title: "Taking over the back button · Agent Wranglers"
url: https://agentwranglers.se/playbook/seo/search-spam-and-penalties/back-button-hijacking
id: SEO-78
level: Avoid
updated: 2026-10-22
build: a2a6bdfed830
tokens: 1003
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Taking over the back button

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Search spam and penalties](https://agentwranglers.se/playbook/seo/search-spam-and-penalties.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: SEO-78
- Level: Avoid
- Chapter: [Search spam and penalties](https://agentwranglers.se/playbook/seo/search-spam-and-penalties.md)
- Rule: 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.
- 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.
- How: 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](https://agentwranglers.se/playbook/app-ui/client-and-server-state/state-in-url.md) says. One press of back must always return to the page the visitor came from.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
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

```python
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"
```

## Sources

- [Google Search Central – A new spam policy for back button hijacking](https://developers.google.com/search/blog/2026/04/back-button-hijacking)
- [Google Search Central – Spam policies](https://developers.google.com/search/docs/essentials/spam-policies)

## Related rules

- APP-31 [Keep screen state in the address](https://agentwranglers.se/playbook/app-ui/client-and-server-state/state-in-url.md) in Web app interface

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/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.

- Previous: [Structured data that misleads](https://agentwranglers.se/playbook/seo/search-spam-and-penalties/misleading-structured-data.md)
- Next: [Keep spam in user posts out of search](https://agentwranglers.se/playbook/seo/search-spam-and-penalties/user-generated-spam.md)
- [Search spam and penalties](https://agentwranglers.se/playbook/seo/search-spam-and-penalties.md)
