Liquid Snippet

Elevate adds a small Liquid snippet to your Shopify theme that powers all experiment delivery on your storefront. This page explains what it does, how it gets there, and what to know about it.


What Is It?

The snippet is a file called elevateab.liquid that lives in your theme's snippets/ folder. It's rendered at the top of your theme.liquid layout file, right after the <head> tag:

<head>
  {% render 'elevateab' %}
  ...
</head>

This snippet is the bridge between your Shopify theme and Elevate's experiment engine. Without it, experiments can't run on your storefront.


What Does It Do?

When a visitor loads a page on your store, the snippet does three things:

  1. Reads experiment configuration — It pulls your active experiments, CSS selectors, and currency formatting from Shopify metafields and makes them available to the page.

  2. Sets up the testing environment — It detects the current page template, active currency, theme ID, and whether the visitor is in a theme preview. This context is used to determine which experiments apply to the current page.

  3. Loads the Elevate script — It injects the lightweight JavaScript that handles visitor assignment, page redirects (for split URL and page tests), and price/content changes. This is the script that actually delivers the experiment to the visitor.

The snippet only runs when the Elevate app is installed on the store. It includes a check (content_for_header contains "elevateab.app") that prevents it from executing if the app isn't active. It also doesn't run in the Shopify theme editor, so it won't interfere with your theme customization.


How It Gets Added

The snippet is deployed automatically — no coding or manual setup required on your part.

When you activate Elevate or launch an experiment, the system:

  1. Creates the snippets/elevateab.liquid file in your active theme

  2. Adds {% render 'elevateab' %} to your layout/theme.liquid file, right after the <head> tag

If your theme uses additional layout files, the snippet render tag is added to those as well.


Automatic Monitoring

Elevate monitors your active theme for the presence of the snippet. If it gets removed — for example, because you switched themes, published a new theme, or manually deleted the file — Elevate automatically redeploys it when you next open the app or launch a new experiment.

You don't need to take any action if this happens. The system handles it.


Performance Impact

The snippet is placed in the <head> section intentionally. This positioning ensures it executes as early as possible, which is critical for:

  • Preventing flicker — Visitors don't see the original version flash before the test variation loads

  • Accurate tracking — Visitor assignment happens before the page renders, so every page view is correctly attributed

In performance testing, the snippet typically adds 1–2 points of impact to page speed scores. This is a marginal tradeoff for accurate experiment delivery and flicker-free rendering.


Important: Don't Remove the Snippet Manually

Removing the elevateab.liquid file or the {% render 'elevateab' %} line from your layout will prevent all experiments from running.

If you need to uninstall Elevate, use the standard Shopify app uninstallation process — this cleanly removes all Elevate code from your theme. Don't manually delete code files, as this can leave behind orphaned references or metafield data.


Troubleshooting

Experiments aren't running on my store Check that the snippet exists in your theme. Go to Online Store → Themes → Edit Code and look for elevateab.liquid in the snippets/ folder. Also check that layout/theme.liquid contains {% render 'elevateab' %} near the top of the <head> section. If either is missing, open the Elevate app — it will automatically redeploy the snippet.

I switched themes and experiments stopped working This is expected. When you publish a new theme, the snippet needs to be added to it. Open the Elevate app or launch/sync an experiment, and the snippet will be deployed to the new theme automatically.

The snippet is there but experiments still aren't working The snippet depends on metafield data being up-to-date. Try syncing your experiment from the experiment settings dropdown — this refreshes the metafield data that the snippet reads.

Last updated