Gumlet Video Snippet for Shopify

A copy-paste Liquid snippet (a small reusable Liquid file, added with {% render %} — not a
full theme-editor "section") that plays one Gumlet hosted video
anywhere in a Shopify theme. Works in any Online Store 2.0 theme (Dawn, Refresh, or a custom
theme). No app install, no JavaScript SDK, no build step — it's one .liquid file.


1. What you need before starting

  • A Gumlet account with the video already uploaded to your Video Library.

  • That video's Asset ID (Gumlet also calls this the Video ID). To find it: open the video in your Gumlet dashboard's Video Library — the ID is shown on the video's detail page, and it's also the part of the embed URL Gumlet gives you, right after /embed/:

    https://play.gumlet.io/embed/ABCD1234EFGH5678
                                   ^^^^^^^^^^^^^^^^ this part is the Asset ID
    
  • Access to edit your Shopify theme's code (Shopify Admin → Online Store → Themes → Edit code), and, if you'll use the metafield method below, access to Shopify Admin → Settings.


2. How it plays a video, in plain terms

Gumlet gives every uploaded video a hosted player page you can embed in an <iframe>, similar to embedding a YouTube video:

https://play.gumlet.io/embed/{asset_id}

You control playback behavior (autoplay, loop, muted, show/hide controls, accent color, etc.) by adding query parameters to that same URL — no JavaScript required for basic playback. This snippet's whole job is: take a few simple settings, build that URL, and print the <iframe>. It also optionally shows a static cover image over the video until someone clicks it, using a small inline <script> (details in §8).


3. Step-by-step setup

Step 1 — Add the snippet file to your theme

  1. In Shopify Admin, go to Online Store → Themes → Edit code (for the theme you want to add this to).
  2. Under the Snippets folder, click Add a new snippet, name it gumlet-video (Shopify will save it as snippets/gumlet-video.liquid).
  3. Copy the entire code block from Full snippet code below and paste it in as the file's
    content. Save.

That's the only file you need to create. The snippet is self-contained — it doesn't require anything to be added to theme.liquid, assets/, or config/settings_schema.json.

Step 2 — Choose how the video's Asset ID reaches the snippet

You have two options. Pick per situation — you can use both across different pages of the same theme.

Option A — Product metafield (recommended for most stores)

Use this when a store admin/merchant (not necessarily a developer) should be able to set, change, or remove a product's video from Shopify Admin, without editing any code.

A metafield is a custom field Shopify lets you attach to a product — like adding your own "Gumlet Video ID" text box to every product page in Admin. Here's how to create one:

  1. In Shopify Admin, go to Settings → Custom data → Products → Add definition.
  2. Name: anything you like, e.g. "Gumlet Video ID".
  3. Namespace and key: type gumlet_video_id in the key field and leave namespace as the default Shopify assigns (custom) — together that gives you custom.gumlet_video_id, which is what this snippet looks for automatically. (You can use a different namespace/key; see the override note in §5.)
  4. Type: choose Single line text.
  5. Save the definition.
  6. Now open any product in Products, scroll down to the Metafields section, and paste that product's Gumlet Asset ID (from §1) into the field you just created. Save the product.

With the metafield filled in, placing {% render 'gumlet-video' %} (see Step 3) on that product's page automatically plays that product's video — no code edit needed to add, change, or remove a video for any given product afterward.

Option B — Hardcode the Asset ID directly in code

Use this when the video isn't tied to editing by a merchant — e.g. a one-off video on a custom landing page, or a temporary video a developer controls directly.

{% render 'gumlet-video', asset_id: 'ABCD1234EFGH5678' %}

(Replace ABCD1234EFGH5678 with your real Asset ID from §1.)

Step 3 — Place the render call

Open whichever .liquid template, section, or snippet file should show the video, and add one line:

{% render 'gumlet-video' %}

Use this exact line if you set up Option A (metafield) above and you're inside a template that has a product object in scope — a product page (PDP) template is the typical place. If you're using Option B (hardcoded ID), add asset_id: '...' as shown above instead.

That's the whole setup. Everything else in this doc is about customizing playback, styling, and a few advanced scenarios.


4. Full snippet code

Paste this into snippets/gumlet-video.liquid (Step 1 above):

{% comment %}
  Gumlet Video — simple snippet
  ---------------------------------------------------------------------------
  Renders one Gumlet video iframe anywhere in the theme. `asset_id` can either
  be passed in directly, or left out entirely so it's read from a product
  metafield instead — see below. Every other param has a default below that
  YOU (dev/admin) edit directly in this file. Any default can be overridden
  per-call if needed.

  Basic usage (asset_id from the current product's metafield — recommended):
    {% render 'gumlet-video' %}

  Basic usage (explicit asset_id):
    {% render 'gumlet-video', asset_id: 'ABCD1234EFGH5678' %}

  With overrides (all optional):
    {% render 'gumlet-video',
      asset_id: 'ABCD1234EFGH5678',
      product_id: product.id,
      metafield_namespace: 'custom',
      metafield_key: 'gumlet_video_id',
      width: 380,
      aspect_ratio: '9:16',
      autoplay: true,
      loop: true,
      muted: true,
      show_controls: false,
      player_color: '#FF6600',
      preload: true,
      rounded: true,
      cover_image: '',
      class: ''
    %}

  `asset_id` (optional): if omitted (or blank), the snippet falls back to
  reading `product.metafields[metafield_namespace][metafield_key].value` on
  whatever product is in scope. This lets a merchant/admin set the video per
  product from Shopify Admin (Product → Metafields) instead of a developer
  hardcoding an ID in Liquid. If both are blank, nothing renders.

  `metafield_namespace` / `metafield_key` (optional): which metafield to read
  the fallback asset ID from. Default to `custom` / `gumlet_video_id` — create
  a single-line-text product metafield with that namespace and key in Shopify
  Admin (Settings → Custom data → Products) to use the defaults as-is.

  `product_id` (optional): pass a specific product ID to restrict this call to
  only render on that product's page (e.g. safe to paste into a snippet that's
  shared across every PDP — it renders nothing unless product.id matches).
  Leave it out to always render regardless of product.
  ---------------------------------------------------------------------------
{% endcomment %}

{% liquid
  # ==== DEFAULTS — edit these to change look/behavior everywhere ====
  assign d_width = 380
  assign d_aspect_ratio = '9:16'
  assign d_autoplay = true
  assign d_loop = true
  assign d_muted = true
  assign d_show_controls = false
  assign d_player_color = ''
  assign d_preload = true
  assign d_rounded = true
  assign d_metafield_namespace = 'custom'
  assign d_metafield_key = 'gumlet_video_id'
  # ====================================================================

  assign gv_metafield_namespace = metafield_namespace | default: d_metafield_namespace
  assign gv_metafield_key = metafield_key | default: d_metafield_key

  assign gv_asset_id = asset_id
  if gv_asset_id == blank and product != blank
    assign gv_asset_id = product.metafields[gv_metafield_namespace][gv_metafield_key].value
  endif

  assign gv_width = width | default: d_width
  assign gv_aspect_ratio = aspect_ratio | default: d_aspect_ratio

  assign gv_autoplay = d_autoplay
  if autoplay != nil
    assign gv_autoplay = autoplay
  endif

  assign gv_loop = d_loop
  if loop != nil
    assign gv_loop = loop
  endif

  assign gv_muted = d_muted
  if muted != nil
    assign gv_muted = muted
  endif

  assign gv_show_controls = d_show_controls
  if show_controls != nil
    assign gv_show_controls = show_controls
  endif

  assign gv_preload = d_preload
  if preload != nil
    assign gv_preload = preload
  endif

  assign gv_rounded = d_rounded
  if rounded != nil
    assign gv_rounded = rounded
  endif

  assign gv_player_color = player_color | default: d_player_color
  assign gv_cover_image = cover_image | default: ''
  assign gv_class = class | default: ''

  assign gv_show = true
  if product_id != nil
    assign gv_show = false
    if product.id == product_id
      assign gv_show = true
    endif
  endif

  assign gv_disable_controls = true
  if gv_show_controls
    assign gv_disable_controls = false
  endif

  assign gv_aspect = gv_aspect_ratio | replace: ':', '/'

  assign gv_params = '?autoplay=' | append: gv_autoplay
  assign gv_params = gv_params | append: '&loop=' | append: gv_loop
  assign gv_params = gv_params | append: '&muted=' | append: gv_muted
  assign gv_params = gv_params | append: '&disable_player_controls=' | append: gv_disable_controls
  assign gv_params = gv_params | append: '&preload=' | append: gv_preload

  if gv_player_color != blank
    assign gv_color_hex = gv_player_color | remove: '#'
    assign gv_params = gv_params | append: '&player_color=%23' | append: gv_color_hex
  endif

  assign gv_src = 'https://play.gumlet.io/embed/' | append: gv_asset_id | append: gv_params
  assign gv_uid = gv_asset_id | md5
%}

{% if gv_asset_id != blank and gv_show %}
  <div
    class="gumlet-video {{ gv_class }}{% if gv_rounded %} gumlet-video--rounded{% endif %}"
    style="--gumlet-video-width: {{ gv_width }}px; --gumlet-video-aspect: {{ gv_aspect }};"
  >
    <div class="gumlet-video__media" data-gumlet-media>
      <iframe
        id="gumlet-iframe-{{ gv_uid }}"
        class="gumlet-video__iframe"
        src="{{ gv_src }}"
        title="Video"
        frameborder="0"
        allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen"
        allowfullscreen
        loading="lazy"
      ></iframe>

      {% if gv_cover_image != blank %}
        <button type="button" class="gumlet-video__cover" data-gumlet-cover aria-label="Play video">
          <img src="{{ gv_cover_image }}" alt="" loading="lazy">
          <span class="gumlet-video__play-icon" aria-hidden="true">
            <svg width="22" height="22" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>
          </span>
        </button>
      {% endif %}
    </div>
  </div>

  {% style %}
  .gumlet-video {
    width: 100%;
    max-width: var(--gumlet-video-width, 380px);
    margin: 0 auto;
  }
  .gumlet-video__media {
    position: relative;
    width: 100%;
    aspect-ratio: var(--gumlet-video-aspect, 16/9);
    background: #000;
    overflow: hidden;
  }
  .gumlet-video--rounded .gumlet-video__media {
    border-radius: 8px;
  }
  .gumlet-video__iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
  }
  .gumlet-video__cover {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    padding: 0;
    margin: 0;
    cursor: pointer;
    background: none;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.35s ease;
  }
  .gumlet-video__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .gumlet-video__cover.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  .gumlet-video__play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
  }
  .gumlet-video__cover:hover .gumlet-video__play-icon {
    transform: translate(-50%, -50%) scale(1.08);
  }
  {% endstyle %}

  {% if gv_cover_image != blank %}
    <script>
      (function () {
        document.querySelectorAll('[data-gumlet-cover]').forEach(function (cover) {
          if (cover.dataset.gumletBound === 'true') return;
          cover.dataset.gumletBound = 'true';
          cover.addEventListener('click', function () {
            cover.classList.add('is-hidden');
          });
        });
      })();
    </script>
  {% endif %}
{% endif %}

5. All the settings you can customize

Every setting below has a default already set in the file (see §6 to change those defaults for every placement at once). None of these are required — pass only the ones you want to change for one specific {% render %} call:

{% render 'gumlet-video',
  asset_id: 'ABCD1234EFGH5678',
  width: 500,
  aspect_ratio: '16:9',
  autoplay: false,
  muted: false,
  show_controls: true,
  player_color: '#FF6600',
  rounded: false,
  cover_image: product.featured_image | image_url: width: 1600,
  class: 'my-extra-class'
%}
Param Type Default (edit in file) Effect
asset_id string (none — falls back to metafield) The Gumlet Asset ID from §1. If omitted/blank, falls back to the product metafield (§3, Option A). If that's also blank, the snippet renders nothing.
metafield_namespace string 'custom' Namespace of the product metafield to read asset_id from when it isn't passed. See §3, Option A.
metafield_key string 'gumlet_video_id' Key of the product metafield to read asset_id from when it isn't passed. See §3, Option A.
width number 380 Max width of the video in px. Container is centered (margin: 0 auto).
aspect_ratio string '9:16' Any w:h ratio string ('16:9', '1:1', '4:3', '21:9', …).
autoplay boolean true Autoplay on load. Browsers force this to also be muted.
loop boolean true Loop playback.
muted boolean true Start muted.
show_controls boolean false Shows Gumlet's native player chrome (seek bar, play button, etc.).
player_color hex string '' (Gumlet default) Accent color for the native player UI, e.g. '#FF6600'.
preload boolean true Preloads the video so there's no play-button delay.
rounded boolean true Adds border-radius: 8px to the video frame.
cover_image string (URL) '' (none) Optional poster image shown over the video until clicked.
class string '' Extra CSS class(es) added to the outer wrapper for custom styling.
product_id number (none — always renders) Optional. Restricts this render call to a single product. See §7.

To read the metafield from a different namespace/key than the default (e.g. one already created by another app), override it per call:

{% render 'gumlet-video', metafield_namespace: 'my_app', metafield_key: 'video_asset_id' %}

asset_id passed explicitly always wins over the metafield. The metafield is only consulted when there's a product object in scope — so it's a no-op on a page, blog, or collection template.


6. Changing the defaults for every placement

Open snippets/gumlet-video.liquid and edit the DEFAULTS block near the top of the file:

assign d_width = 380
assign d_aspect_ratio = '9:16'
assign d_autoplay = true
assign d_loop = true
assign d_muted = true
assign d_show_controls = false
assign d_player_color = ''
assign d_preload = true
assign d_rounded = true
assign d_metafield_namespace = 'custom'
assign d_metafield_key = 'gumlet_video_id'

Every existing {% render 'gumlet-video', ... %} call across the theme that doesn't explicitly override a given param picks up the new default immediately — no need to touch every call site. That includes d_metafield_namespace/d_metafield_key: change them here if your metafield lives under a different namespace/key than custom.gumlet_video_id.


7. Scoping one render call to a single product

This is only relevant if you're hardcoding an asset_id (§3, Option B) inside a template or snippet that's shared across every product — e.g. a shared product-gallery snippet — but you only want the video to show up on one specific product's page:

{% render 'gumlet-video',
  asset_id: 'ABCD1234EFGH5678',
  product_id: 8123456789012
%}
  • If product_id is omitted, the snippet always renders (as long as asset_id is set) — unaffected by which product is being viewed.
  • If product_id is set, the snippet compares it against product.id of the product currently being rendered and only outputs the video when they match. On every other product it renders nothing at all (not even an empty wrapper div).

Find a product's numeric ID in Shopify Admin: open the product in Products, and the ID is in the page URL (.../products/8123456789012). You can also temporarily print {{ product.id }} anywhere on that product's page to read it.

For the common case of "one product gets a video, set by whoever manages the catalog" — prefer the metafield method (§3, Option A) instead. It needs no product_id/asset_id targeting logic at all: set the metafield on the one product you want, leave it blank everywhere else, done. Reach for product_id + a hardcoded asset_id when the video ID isn't something you want exposed as an editable metafield (e.g. it's temporary, or should only be set by a developer).


8. Why this uses inline {% style %}/<script> instead of {% stylesheet %}/{% javascript %}

(For developers — merchants/admins can skip this section.)

Shopify's {% stylesheet %} and {% javascript %} tags are only valid inside section files — they compile into separate bundled assets tied to that section. A snippet doesn't have that asset pipeline, so those tags would be invalid there. This snippet uses:

  • {% style %}...{% endstyle %} — valid anywhere (sections, snippets, layout), outputs scoped inline CSS.
  • A plain inline <script> tag, only emitted when cover_image is set, guarded by a data-gumlet-bound flag so re-running it on a page with multiple video snippets doesn't double-bind click handlers.

If the same snippet is rendered more than once on a page, its {% style %} block and (if used) <script> block are duplicated per call — harmless (idempotent CSS/JS), just not deduplicated the way section assets are. Not a concern for typical usage (a handful of video placements per page).


A common placement is inside the product image gallery on a product page (PDP), so the video shows up alongside the product photos. How you do this depends on how your theme's gallery is built:

If the gallery is a plain loop over images (no JS carousel/slider) — this is the simple case. Find the Liquid loop that outputs each product image (usually something like {% for image in product.images %} inside a gallery snippet/section), and drop the render call in next to it, gated on the metafield being set so it only appears for products that have a video:

{% if product.metafields.custom.gumlet_video_id.value != blank %}
  {% render 'gumlet-video' %}
{% endif %}

Place that before or after the image loop depending on whether you want the video first or last in the gallery. That's it for this case — no other changes needed.

If the gallery is a JS carousel/slider (Splide, Swiper, Slick, native scroll-snap, etc.) — the video needs to become one slide among the others, so a few extra things apply:

  • Still drive asset_id from the product metafield (as above) rather than hardcoding an ID — it keeps the per-product logic to a single {% if %}, no config block to maintain.
  • Wrap the {% render 'gumlet-video' %} call in whatever slide markup/classes your carousel expects each item to have (e.g. the same wrapper element and class the image slides use), so the carousel library recognizes and sizes it correctly.
  • If the gallery has a synced thumbnail rail alongside the main image row (clicking a thumbnail scrolls the main row, or vice versa), most sync implementations require both rails to have the same number of slides in the same order — so a video slide has to be added to both rails, and the thumbnail rail needs a corresponding thumbnail for it too (e.g. a play-icon graphic).