Skip to main contentSkip to footer
    Back to Case Studies
    CavemanCoffee Co.
    E-CommerceShopifyCloudflare Workers

    Drink Caveman

    A coffee brand on Shopify wanted a bundle offer that only paid social and email subscribers could reach, on a page with no way out except checkout, without touching the live store. We built the gate at the edge, the funnel in a duplicate theme, and wrote the whole thing down so it can be repeated.

    Project Preview

    Live website preview - drinkcaveman.com

    10/10
    Cryptographic unit tests passing
    30 d
    Meta ad token lifetime
    365 d
    Klaviyo email token lifetime
    12/12
    Manual QA checks passed on the staging theme

    HMAC-SHA256 signed URLs

    Every ad and email link carries a signed token with a version, campaign, expiry and nonce. Tampered, expired, malformed or wrong-secret tokens are all rejected.

    Cloudflare Worker gate

    A Worker on a workers.dev subdomain verifies the token, issues a signed session cookie and redirects into the funnel with UTMs preserved. No DNS migration.

    Duplicate-theme funnel mode

    The gate code lives in one block in a duplicate of the live theme. The live theme is never pushed to, and rollback is publishing the previous theme.

    No escape paths

    In funnel mode the header, footer, announcement bars, search and drawers are hidden. The bundle collection is hidden from navigation and disallowed for crawlers.

    iOS-safe cart

    Add-to-cart and the cart icon are intercepted in the capture phase and sent to the full cart page, bypassing a drawer that froze iOS Safari.

    Staging and production

    Separate staging and production Workers, a phase-gated execution checklist with stop conditions, and a generalised playbook for other stores.

    The problem

    Drink Caveman sells coffee on Shopify and runs Meta ads and Klaviyo email flows. The brand wanted to send that paid and owned traffic to a bundle offer that the rest of the internet could not find: not in navigation, not in search, not discoverable by someone typing the collection URL, and not indexed by Google. Once a visitor was in, the page should have nothing to click except add-to-cart and checkout.

    Shopify does not offer that. A collection is either published or it is not, and a password-protected store locks out everyone. Landing-page apps solve the layout but not the access control, and they cannot reach into the cart and checkout. The live theme, meanwhile, was carrying real revenue and could not be edited in place.

    What the store needed

    • Access control that cannot be guessed: Links that prove where a visitor came from, expire on a schedule, and can be invalidated.
    • A funnel with no exits: Bundle page, cart, checkout. No header, no footer, no product detail pages, no search.
    • Zero risk to the live store: Nothing pushed to the published theme until an explicit sign-off.
    • Repeatable: The same pattern for the next campaign, the next page and the next store.

    How it works

    The token

    A token is a base64url payload carrying a version, a campaign name, an expiry timestamp and a random nonce, followed by an HMAC-SHA256 signature over that payload. A command-line tool mints one for a named campaign with a lifetime in days: 30 days for a Meta ad set, 365 for the evergreen link in Klaviyo flows, one day for a smoke test. A companion tool verifies any full URL. Ten unit tests on the Node test runner cover the acceptance and rejection cases: valid, expired, wrong secret, tampered payload, no separator, empty, null, missing campaign, unknown version, and that the TTL is reflected in the expiry.

    The Worker

    The ad or email link points at a Cloudflare Worker's verify route with the token and UTM parameters. The Worker checks the signature, version, expiry and campaign field. On success it sets a signed session cookie and answers with a 302 to the bundle collection on the store, appending a flag and passing the UTMs through. On failure, whether expired, forged or replayed, it 302s to the homepage. A separate check route reports whether the visitor holds a valid cookie, kept available as a fallback path. The Worker runs on a workers.dev subdomain, so the store's DNS was never touched, and staging and production Workers are deployed under separate names.

    Funnel mode in the theme

    The live theme was duplicated and the duplicate received a single, delimited block in the head of the theme layout. Guarded by Liquid conditionals, it has no effect anywhere outside the funnel. When the redirect flag is present, an inline script sets a sessionStorage marker and adds a class to the root element; every page in that tab then renders in funnel mode. Scoped CSS hides the desktop header, footer, app-injected announcement bars, cart and size-guide drawers, quiz overlays and search, while leaving the mobile nav bar with only a hamburger and a cart icon. The bundle link is hidden from every navigation menu site-wide and the collection is disallowed in robots.txt with a noindex meta tag.

    On the cart page, the same class hides the chrome and the redundant update button, and quantity buttons are intercepted so each change posts to the cart API and reloads, keeping the visible subtotal accurate. Checkout is the only remaining exit.

    What shipped

    Worker with token verification, signed cookie and fallback redirect, plus Wrangler config for staging and production
    Token library with HMAC-SHA256 sign and verify, and a signed session cookie module
    Mint, verify and preflight command-line tools, with ten passing unit tests
    Theme layout, sections, snippets, assets and a collection template for the funnel, applied to a duplicate theme
    Robots and noindex controls so the gated collection stays out of search
    A phase-gated agent execution checklist with explicit stop conditions and rollback procedures
    A funnel-page runbook and deployment report documenting every selector, constant and gotcha

    Problems worth talking about

    The iOS freeze

    The theme's cart drawer locks body scroll, which on iOS Safari looks like a frozen page. Rather than fight the drawer, add-to-cart submits and cart-icon clicks are captured at the document level before the theme's handlers run, then routed to the full cart page.

    One pixel, one event

    Shopify's native Meta channel already fires a PageView. Installing a second pixel would double-count AddToCart. The funnel hooks the existing pixel function instead, verified with Pixel Helper before launch.

    App bars that fight back

    Third-party announcement bars inject their own important display rules after the CSS loads. An inline style property set with the important flag wins at equal specificity, applied on DOM ready.

    Rollback is one click

    Because the funnel lives in a duplicate theme, the previous live theme stays unpublished but intact. Restoring the store is publishing it again. A leaked token is handled by rotating the signing secret and re-minting.

    Verification

    The deployment report from 12 May 2026 records the results. Ten of ten unit tests pass. The manual QA matrix on the staging theme passed all twelve checks: a valid token renders the funnel, a missing or garbage token redirects home, the token disappears from the URL while UTMs are preserved, a reload on the cookie still renders, the homepage is untouched for organic visitors, every escape path is blocked, add-to-cart lands on the cart page, quantity and removal work, checkout completes, a real mobile device passes, and the pixel fires once per event. A test purchase was placed and refunded, and the Klaviyo path was exercised end to end from a real inbox. Playwright drives the same flow at a 390 by 844 viewport for regression checks, with a real-device iOS pass required after it.

    The playbook

    The store-specific values are tabulated in one place: the gated path, the fallback URL, the origin host, the header section selector, the URL flag convention. The runbook explains how to gate a second page, when to re-duplicate the theme after a live-theme change, and what shipping changes do and do not require. The generalised procedure was extracted into a separate gated-URL playbook so the same pattern can be applied to any Shopify store.

    Where it stands

    What we can and cannot claim

    The funnel was built, staged and verified in May 2026 and is production-ready pending the client's sign-off to publish the duplicate theme; until then, the staging Worker serves the links. The test counts above are taken from the deployment report and the test suite. Wiring the provisioned KV namespaces for rate limiting and per-campaign revocation is a documented next step. We have no ad-account or store analytics access for this client, so this page carries no ROAS, session or revenue figures.

    If any verification step fails, stop and report. Do not fix and continue without explicit human approval.

    Agent execution checklist, drinkcaveman.com

    What This Project Does Well

    Organic visitors never see the offer: a direct hit on the gated collection without a token is redirected to the homepage
    One signed URL per channel: a 30-day token for Meta ads, a 365-day evergreen token for Klaviyo flows, each tagged with its campaign
    The Meta Pixel fires exactly once per event by hooking the store's existing pixel instead of installing a second one
    Funnel mode lives in sessionStorage, so it dies with the tab and a returning organic visitor sees the normal store
    Cart quantity changes go through the cart API and reload, so the subtotal a customer sees is always correct
    A full test purchase, refund, real-device mobile QA and a Klaviyo email round-trip were completed before sign-off
    Every store-specific value is tabulated, with a console one-liner to re-derive the theme's header section ID on a new store

    Technologies Used

    Shopify (Liquid theme, cart AJAX API), Cloudflare Workers and Wrangler, Workers KV, HMAC-SHA256 via Web Crypto, Node.js 18+ CLI tooling (mint, verify, preflight), Node test runner, Klaviyo, Meta Ads and Meta Pixel, Playwright end-to-end verification, Shopify CLI

    Ready to Build Something Similar?

    Let's discuss how we can help transform your business with a custom digital solution.