Marketing
Product video showcases in Go
A Go package that puts a store’s own videos beside the products they show. A showcase is a link to a video on YouTube or Facebook, the products in it, and which one is being shown now. The storefront plays the platform’s own player and sells through the ordinary cart. Nothing is uploaded, transcoded or streamed by the store.
- Marketing module
- 3 settings
- 21 tests
- 11 API operations
- ext/showcases
What it does
In the package’s own words, a showcase is “a store’s own people showing the products it sells, in a video on YouTube or Facebook, beside those products”. A shop already films that for its social pages; the module lets the storefront show it next to those products and sell them through the ordinary cart.
A pasted address is checked against the share formats each platform documents and kept as a reference: YouTube’s video id, or Facebook’s canonical video address. The player’s address is built from that reference every time a showcase is read, so nothing a merchant types is put on a page as markup, and a change of embed format reaches every showcase at once.
The products are picked by hand, up to 50, or come from a collection read when the showcase is shown. A buyer sees only active products the request’s channel carries, in the request’s language, as a short summary: title, picture, the default variant’s price and compare-at price, and whether it can be bought. Cost, stock counts and metadata are left out.
A showcase is a recording or a livestream. The module does not claim more than it knows: a livestream reads “live” only after the store presses We’re live in the editor, and for twelve hours after. In the package’s words, “there are no viewer counts and no badges.”
Configuration
Nothing has to be set: the zero Config is what a store runs. All three fields are Go only, and there are no settings on the Plugins screen. Showcases themselves are made on the admin’s Content › Video showcases screen.
| Setting | Environment variable | Required | What it does |
|---|---|---|---|
EventsPerMinute | — | No | Bounds the views and clicks the store counts from one address for one showcase in a minute. Zero is 600. Go only. |
YouTubeOEmbedURL | — | No | Replaces YouTube’s oEmbed endpoint, https://www.youtube.com/oembed, which the link check asks. For tests; empty for production. Go only. |
HTTPClient | — | No | Replaces the client that asks YouTube. Otherwise the module uses the install’s outbound client with a five-second timeout. For tests; Go only. |
The module reads its Config struct, not the environment. The variable names are the ones the package’s own example or the reference binary uses; in your own main() you choose where each value comes from. Where a setting has a panel label, the admin’s settings drawer can hold it too, and a value typed there wins over Config.
Setting it up
- Install the modulePass showcases.New to gocommerce.New, as below, or start the reference binary with -showcases. It adds five tables, and the Video showcases plugin starts switched on.
- Paste the video’s linkOn Content › Video showcases, paste the video’s own link. For a YouTube video the editor asks YouTube for its title and says if it is private or cannot be played on another site.
- Attach products and publishPick up to 50 products or a collection, choose where it appears (the home page, the pages of its products, its collection’s page) and publish. A showcase with no products cannot be published.
- Show it on the storefrontGET /x/showcases?on=home, ?product=<id> or ?collection=<id> lists the cards; GET /x/showcases/{slug} gives the player and the products. Report views, clicks and adds with POST /x/showcases/{slug}/events.
main.go
import (
"github.com/itswadesh/gocommerce/core"
"github.com/itswadesh/gocommerce/ext/showcases"
)
app, err := gocommerce.New(cfg,
// EventsPerMinute bounds views and clicks from one address; zero means 600.
showcases.New(showcases.Config{}),
) The package doc has no example of its own; this is how the reference binary’s -showcases flag installs it. cfg is your gocommerce.Config. Import path github.com/itswadesh/gocommerce/ext/showcases.
How it works
-
The platform’s own player
YouTube plays from youtube-nocookie.com/embed, its privacy-enhanced embed, with a still from i.ytimg.com; Facebook plays in its video plugin. A watch URL opens the video on the platform when the player cannot. The address the store pasted is left out of the public answer.
-
Only links that name a video
youtube.com/watch, youtu.be, /live/, /shorts/, /embed/ and /v/ for YouTube; /watch, video.php, /reel/ and a page’s /videos/ for Facebook. A channel or page is refused with what to paste instead. A fb.watch or /share/ short link is refused rather than followed from the server.
-
A link check before publishing
POST /api/admin/x/showcases/check asks YouTube’s oEmbed endpoint, within five seconds, for the video’s title and whether it may play elsewhere. A private video, or one whose owner turned off embedding, comes back with what to change in YouTube Studio. YouTube being slow is not a refusal. Facebook’s oEmbed needs an app token, so a Facebook link is checked by its preview alone.
-
Counted without knowing the buyer
Views, clicks and adds to the cart are counted per showcase per day, and nothing about the buyer is kept. An add that carries its cart token ties that basket to the showcase, the last one to add to it. When the basket becomes an order, order.created credits the order and its total to that showcase once.
-
Rate-limited by address
Views and clicks from one address for one showcase are capped per minute, 600 by default; past it the answer is 429 with Retry-After. An add with its basket is not capped but is counted once per basket, because behind a proxy every buyer shares one address. X-Forwarded-For is not read.
-
A small route for broadcasts
GET /x/showcases/{slug}/now answers only the label and the product being shown, cacheable for five seconds, for a storefront to ask every few seconds during a livestream.
-
Its own rights
showcases.read for managers and staff, showcases.write for managers. Turning a showcase’s picks into a collection of their own, with POST /api/admin/x/showcases/{id}/collection, needs collections.write as well.
What it does not do
Read these before an order depends on it. No store is known to run GoCommerce in production yet, so these come from the code, not from anyone’s experience.
- No video hostingNo upload, no transcoding and no stream. Only YouTube and Facebook links are accepted. A video removed or made private on the platform later stops playing, and the module is not told.
- Live is the store’s wordThe label never comes from the link. A livestream nobody marked live shows as a video. One marked live and never ended reads live for up to twelve hours, then as a replay.
- The check warns, it does not refuseA private or non-embeddable YouTube video can still be saved and published; the check only tells the merchant. Facebook videos are not checked with Facebook at all, and have no thumbnail.
- The store’s own priceA showcase shows the default variant’s price. Price lists apply in the cart, against an address the buyer has proven, so a customer’s own price appears only there.
- Fifty productsA hand-picked list holds at most 50 products. A collection can hold more, but a showcase reads at most 50 of it when shown.
- Counts per showcase onlyThe event route accepts a product id and does not keep it, so there are no per-product counts. The rate limit is held in each process’s memory, so several instances each count their own. The event route is public, so counts can be inflated up to that limit.
- Three places on the storefrontThe public list filters for the home page, a product’s page or a collection’s page, or lists every published showcase. A showcase is listed on a collection’s page only when its products come from that collection.
FAQ
Questions about the Video showcases module
Does the store host the videos?
No. The video stays on YouTube or Facebook. The module keeps a reference to it and builds the platform’s own player from that reference, so there is nothing to upload and no video traffic through the store.
Which links can I paste?
A YouTube video’s own link (watch, youtu.be, live, shorts or embed), or a Facebook video’s address from the browser’s address bar (watch, video.php, reel, or a page’s videos). A channel, a page, or a short share link such as fb.watch is refused, with a message saying what to paste instead.
How does a livestream show as live?
Only when the store says so. Set the showcase’s kind to a livestream, give it a start time and press Scheduled to read “scheduled”, press We’re live when the broadcast starts and Ended when it stops. A broadcast left live reads as a replay after twelve hours.
What do the counts measure?
Views, clicks and adds to the cart, as the storefront reports them, per showcase per day, and the orders and revenue from baskets a showcase filled, each order counted once. Nothing about the buyer is stored.
Is this a YouTube or Facebook partnership?
No. The module embeds the players both platforms publish for other sites and asks YouTube’s public oEmbed endpoint about a link. Neither endorses GoCommerce, and no store is known to run this module in production.
Source
Everything on this page is read from ext/showcases in the GoCommerce repository, MIT licensed. When this page and the code disagree, the code is right and this page is out of date.YouTube and Facebook are trademarks of their owners; this module embeds their published video players and asks YouTube’s public oEmbed endpoint about a pasted link, and implies no endorsement. See trademarks.
Try it against a store of your own
The backend + admin quick start runs GoCommerce’s API and admin on your own machine, without a storefront. Add this module to it and try it on test orders before a real one depends on it.