Skip to content

feat: let owners show calls to action in the player and collect leads from them - #9

Merged
its-gabo merged 1 commit into
mainfrom
gs_feat_add_calls_to_action_in_player
Nov 21, 2026
Merged

its-gabo merged 1 commit into
mainfrom
gs_feat_add_calls_to_action_in_player

Conversation

@its-gabo

Copy link
Copy Markdown
Owner

Summary

Owners can now put calls to action on a video: a button that opens a link, or a form that collects email addresses. A call to action shows over the video while it plays, at a fixed time or at a random moment inside a window, or on an end screen once the video ends. Email forms need a ticked consent checkbox, and every lead keeps the exact consent text the viewer agreed to.

Leads have their own page, where members can search them, export them as CSV and delete them. Servers can read leads with a new leads:read API key scope, and a new video.cta.submitted webhook sends each lead as it comes in. Video analytics show, for each call to action, how many views saw it, answered it and closed it.

What owners see

  • Calls to action tab in the video sheet. It lists the video's calls to action in playback order, each with its kind and timing, for example "Button · 0:12–0:19" or "Random between 0:30 and 2:00, for 10 seconds".
    • Add call to action opens a dialog with these settings:
      • Kind: button or email form.
      • Placement: over the video or end screen.
      • When, for overlays: at a fixed time or at a random time.
      • Times: start and end. For a random time, a window and how long it stays.
      • Text: heading, optional text and button label.
      • Link for a button, or consent text for an email form.
      • Viewers can close it.
    • Use player time fills the start from the player above.
    • The player above previews the calls to action. It counts nothing and takes no email addresses.
    • A video can have up to 10 calls to action, and at most one end screen.
  • Leads tab in the library. It lists the email addresses viewers left, newest first, with the video, the call to action, the site and when they consented. Hovering the date shows the consent text.
    • Search matches the email address.
    • Export CSV downloads every lead of the library.
    • Delete removes a lead for good, for example when the viewer asks to be forgotten.
  • Video analytics. A Calls to action card shows, for each one, how many views saw it, the share that answered it (a click for a button, an email address for a form) and the share that closed it.
  • Embed code. A new Show calls to action switch, on by default.
  • API keys. A new Read leads permission.
  • Webhooks. A new Leads group with the video.cta.submitted event.
  • Activity log. New entries: "Added a call to action", "Changed a call to action", "Deleted a call to action", "Deleted a lead" and "Exported leads".

What viewers see

  • Overlay. A card in the top-right corner while the call to action is due, with a heading, optional text and either a button or an email form. A button opens its link in a new tab.
    • Random time. Each playback picks its own moment inside the window. Seeking or pausing doesn't pick a new one.
    • If two overlays are due at once, the one that starts first shows.
  • End screen. A card over the last frame once the video ends.
    • In a playlist, the next video's countdown waits until the viewer closes the end screen.
  • Email form. The button stays disabled until the address is valid and the consent box is ticked. After sending, the card thanks the viewer and can always be closed. Sending again in the same view changes nothing.
  • Closing. A close button shows when the call to action is dismissible, or once the viewer has answered it. A closed call to action stays away for the rest of that video.
  • Hiding them. ?ctas=0 on an embed URL hides every call to action, for sites that place a video without its marketing.

Changes

API

New endpoints, for members and for library API keys:

Member route Library API route Scope
GET …/videos/:videoId/ctas GET /libraries/:id/videos/:videoId/ctas videos:read
POST …/videos/:videoId/ctas POST /libraries/:id/videos/:videoId/ctas videos:manage
PUT …/videos/:videoId/ctas/:ctaId PUT /libraries/:id/videos/:videoId/ctas/:ctaId videos:manage
DELETE …/videos/:videoId/ctas/:ctaId DELETE /libraries/:id/videos/:videoId/ctas/:ctaId videos:manage
GET …/libraries/:id/leads GET /libraries/:id/leads leads:read
GET …/libraries/:id/leads/export
DELETE …/libraries/:id/leads/:leadId

Public, without an API key:

Route Does
GET /libraries/:id/videos/:videoId/embed/ctas Returns the calls to action the player shows, under the library's playback rules
POST /libraries/:id/videos/:videoId/views/:viewId/ctas/:ctaId/events Records that the view showed, clicked or dismissed a call to action
POST /libraries/:id/videos/:videoId/views/:viewId/ctas/:ctaId/leads Takes { email, consent: true } from an email form
  • Bodies. Create and update take the whole call to action: { kind, placement, startSeconds, endSeconds, timing?, durationSeconds?, heading, body, buttonLabel, buttonUrl, consentText, dismissible }.

    • Button vs. email form. A button needs an https:// link and no consent text. An email form needs consent text and no link.
    • Overlay vs. end screen. An overlay needs a start, and its end may be null (until the video ends). An end screen has no times.
    • Random timing. timing defaults to fixed. A random overlay needs an end and a durationSeconds of at least 1 second, and the window must be at least that long.
    • Video fit. The video must be processed, and its times must fit its duration.
    • No-op saves. Saving the same fields again changes and records nothing.
  • Embed. Video and playlist embeds include a ctasUrl that carries the embed's signature.

  • Events and leads. Both need a view that started in the last 12 hours, so only a player that started one can report. A view counts each event once per call to action, and leaves at most one lead in each.

  • Leads survive deletion. A lead stays when its call to action or video is deleted. It keeps the call to action's heading and the video's title, and its ctaId and videoId become null.

  • CSV export. Its columns are email, consented_at, consent_text, video_title, cta_heading, embedding_host, video_id, cta_id. A cell that starts with =, +, - or @ gets a leading ', so spreadsheets don't run viewer input as a formula.

  • Analytics. Video analytics include ctas: for each call to action, the views that showed, clicked, answered and dismissed it.

  • Webhook. video.cta.submitted sends the lead: { id, libraryId, videoId, ctaId, email, consentText, consentedAt, ctaHeading, videoTitle, embeddingHost }.

  • Activity log. The video.cta_created, video.cta_updated, video.cta_deleted, lead.deleted and library.leads_exported actions, and a new lead resource type. A deleted lead's entry names its call to action, never its email address.

  • Errors.

    Status Code When
    404 video.cta.not_found The call to action doesn't exist on this video
    404 video.cta.lead.not_found The lead doesn't exist in this library
    404 video.view.not_found The view doesn't exist for this video, or no longer takes reports
    409 video.not_ready The video isn't processed yet
    409 video.cta.end_screen_taken The video already has an end screen
    409 video.cta.limit_reached The video already has 10 calls to action
    422 video.cta.out_of_range The times don't fit the video's duration
    422 video.cta.not_an_email_form A lead was sent to a button
    422 validation.fail Any other invalid body, including consent not given
  • Not rate-limited yet. The public lead endpoint relies on needing a view that only a player knows. Rate limiting comes in its own PR.

Migrations

0013_add_video_calls_to_action.sql

  • video_ctas. Belongs to one video through a foreign key that includes the library and organization. Checks enforce:
    • kinds, placements and timings from the shared constants
    • the fields each kind and placement needs
    • https:// links, non-blank text, and at least 1 second shown
    • at most one end screen per video, through a partial unique index
  • video_view_ctas. One row per view and call to action, with when each was shown, clicked, dismissed or answered. Deleting the view or the call to action deletes its rows.
  • video_cta_leads. Leads, with the consent text and the call to action's heading and video's title copied in. They are deleted only with their library. (view_id, cta_id) is unique.
  • Checks. The new scope, webhook event, activity actions and resource type are allowed.

Shared

  • Constants. VIDEO_CTA_KINDS, VIDEO_CTA_PLACEMENTS, VIDEO_CTA_TIMINGS, VIDEO_CTA_EVENT_TYPES and VIDEO_CTA_LIMITS.
  • Schemas. videoCtaInputSchema and videoCtaLeadInputSchema, used by the API and the player.
  • Embed. The ctas embed query key.

Web

  • Player. VideoPlayer takes ctas.
    • New pieces: PlayerCtaCard, usePlayerCtas (which call to action shows when, including random moments) and useCtaReporting (events and leads, queued until the view starts).
    • useViewReporting now returns the latest view's id, which stays after the video ends, so the end screen can report.
  • Embed.
    • useEmbedCtas reads the embed's ctasUrl.
    • Fix: the player now renders only in the browser, inside ClientOnly. The server rendered it before, and it threw "document is not defined" while checking HLS support, so the embed page fell back to rendering in the browser.
  • Dashboard.
    • VideoCtasSection and VideoCtaDialog in the video sheet.
    • The Leads route.
    • The CtaBreakdown analytics card.
  • Translations. English and Polish for everything new.

@its-gabo its-gabo self-assigned this Nov 21, 2026
@its-gabo
its-gabo merged commit 66acc44 into main Nov 21, 2026
1 check passed
@its-gabo
its-gabo deleted the gs_feat_add_calls_to_action_in_player branch November 22, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant