Law firm sites are a hard place to run A/B tests. Traffic is modest, the conversion that matters is a phone call, and the pages being tested are often the same charge pages that bring in most of the firm's search traffic. Add a client-side testing script that hides the page until it swaps in a variant, and you can hurt both the visitor experience and search performance while trying to improve conversions.
This post covers a setup that avoids the two most common problems: the flicker of original content before a variant appears, and test configurations that confuse search engines. It is aimed at developers and technical marketers who maintain sites for criminal defense firms, though most of it applies to any small service business.
Where flicker comes from
Most client-side testing tools work by loading the original page, then running JavaScript that changes headings, buttons or layout for visitors in the variant group. If the script loads late, visitors briefly see the original before it changes. To hide this, many tools add an anti-flicker snippet that sets the page to invisible until the test script finishes.
On a fast connection that delay is short. On a phone with a weak signal, which describes a lot of people searching for a lawyer late at night, the page can stay blank for a noticeable time. That blank period can lower conversions across both groups, which muddies the test and costs real calls.
Assigning variants at the edge
A cleaner approach is to decide the variant before the HTML reaches the browser. Most modern hosts offer some kind of edge function or middleware that runs before a request is served. The function checks for a cookie, assigns a group if there is none and serves the matching version of the page.
export default async function (request, context) { const url = new URL(request.url); if (url.pathname !== "/dui-defense/") return context.next(); let group = context.cookies.get("ab_dui"); if (!group) { group = Math.random() < 0.5 ? "a" : "b"; const expires = new Date(Date.now() + 30 * 864e5); context.cookies.set({ name: "ab_dui", value: group, path: "/", expires }); } if (group === "b") return new URL("/variants/dui-defense-b/", request.url); return context.next(); } The visitor's address bar still shows the original URL, and no client-side swap happens, so there is no flicker. The example follows the style of Netlify's edge functions, where returning a URL rewrites the request. Other hosts have their own APIs, so adapt the cookie and rewrite calls to your platform.
Keeping search engines out of trouble
Google publishes guidance on running tests without harming search performance. The main points are simple to follow on a law firm site:
- Do not cloak. Googlebot should be treated like any other visitor and can be assigned to a group like anyone else. Do not detect crawlers and always serve them the original.
- If a variant lives at a separate URL, add a rel=canonical tag on it that points to the original page, so the variant is not indexed as a duplicate.
- If you redirect visitors to a variant URL, use a temporary 302 redirect rather than a permanent 301.
- End the test once you have a result, then update the original page and remove the test code.
With an edge rewrite, the variant shares the original URL, so canonical tags matter less. Still add a noindex or canonical tag to the variant files themselves in case they are ever reached directly.
Measuring the right conversion
A test that measures form starts or button clicks may pick a winner that does not bring in more cases. Record the group in your analytics events for calls and form submissions, and pass it to your call tracking tool if it accepts custom fields. That lets you compare actual call volume by variant.
Expect low traffic to limit what you can learn. Test large differences, such as a rewritten first screen, rather than small ones like button color. For a charge page that already ranks, read this guide on testing changes to a charge page without hurting its rankings before changing headings or main copy in a variant.
Cleaning up after the test
Leftover test code causes problems months later. When a test ends, remove the edge function or set it to always serve the winning version, delete the variant files, and clear the cookie by setting it to expire. Update the original page with the winning content so the test infrastructure can go.
Keep a short log in the repository: dates, hypothesis, variants, traffic, result and the commit that shipped the change. More notes on conversion testing for law firm websites are collected in the conversion testing guides for law firm sites.
Questions about A/B testing law firm sites
Does A/B testing hurt SEO?
Not when it follows Google's guidance: no cloaking, canonical tags on variant URLs, temporary redirects and tests that end once there is a result.
How long should a test run on a low-traffic site?
Long enough to collect a meaningful number of calls in each group, which may take weeks or months. Avoid stopping a test early on the first good week.
Should I test on the homepage or a charge page?
Charge pages often get more qualified traffic. Test where the visitors who call actually land, which your analytics can show.
SBD Marketing works only with criminal defense law firms, one firm per city. It builds defense firm websites, handles SEO for the charges a firm defends, works on visibility in AI search tools and runs SEO audits.