Repository navigation
feat: let owners show calls to action in the player and collect leads from them - #9
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:readAPI key scope, and a newvideo.cta.submittedwebhook 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
video.cta.submittedevent.What viewers see
?ctas=0on 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:
GET …/videos/:videoId/ctasGET /libraries/:id/videos/:videoId/ctasvideos:readPOST …/videos/:videoId/ctasPOST /libraries/:id/videos/:videoId/ctasvideos:managePUT …/videos/:videoId/ctas/:ctaIdPUT /libraries/:id/videos/:videoId/ctas/:ctaIdvideos:manageDELETE …/videos/:videoId/ctas/:ctaIdDELETE /libraries/:id/videos/:videoId/ctas/:ctaIdvideos:manageGET …/libraries/:id/leadsGET /libraries/:id/leadsleads:readGET …/libraries/:id/leads/exportDELETE …/libraries/:id/leads/:leadIdPublic, without an API key:
GET /libraries/:id/videos/:videoId/embed/ctasPOST /libraries/:id/videos/:videoId/views/:viewId/ctas/:ctaId/eventsPOST /libraries/:id/videos/:videoId/views/:viewId/ctas/:ctaId/leads{ email, consent: true }from an email formBodies. Create and update take the whole call to action:
{ kind, placement, startSeconds, endSeconds, timing?, durationSeconds?, heading, body, buttonLabel, buttonUrl, consentText, dismissible }.https://link and no consent text. An email form needs consent text and no link.null(until the video ends). An end screen has no times.timingdefaults tofixed. Arandomoverlay needs an end and adurationSecondsof at least 1 second, and the window must be at least that long.Embed. Video and playlist embeds include a
ctasUrlthat 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
ctaIdandvideoIdbecomenull.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.submittedsends 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.deletedandlibrary.leads_exportedactions, and a newleadresource type. A deleted lead's entry names its call to action, never its email address.Errors.
video.cta.not_foundvideo.cta.lead.not_foundvideo.view.not_foundvideo.not_readyvideo.cta.end_screen_takenvideo.cta.limit_reachedvideo.cta.out_of_rangevideo.cta.not_an_email_formvalidation.failNot 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.sqlvideo_ctas. Belongs to one video through a foreign key that includes the library and organization. Checks enforce:https://links, non-blank text, and at least 1 second shownvideo_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.Shared
VIDEO_CTA_KINDS,VIDEO_CTA_PLACEMENTS,VIDEO_CTA_TIMINGS,VIDEO_CTA_EVENT_TYPESandVIDEO_CTA_LIMITS.videoCtaInputSchemaandvideoCtaLeadInputSchema, used by the API and the player.ctasembed query key.Web
VideoPlayertakesctas.PlayerCtaCard,usePlayerCtas(which call to action shows when, including random moments) anduseCtaReporting(events and leads, queued until the view starts).useViewReportingnow returns the latest view's id, which stays after the video ends, so the end screen can report.useEmbedCtasreads the embed'sctasUrl.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.VideoCtasSectionandVideoCtaDialogin the video sheet.CtaBreakdownanalytics card.