cta-end

Package: @playerstack/plugin-cta-end (source), not published to npm yet

When the video ends, render an overlay with optional title, custom HTML, anchor button (label + URL + UTM), and replay. Hook into the event bus for analytics.

Quickstart

<player-stack
  src="https://youtu.be/dQw4w9WgXcQ"
  data-config='{
    "ctaEnd": {
      "enabled": true,
      "title": "Want the deep dive?",
      "button": {
        "label": "Get the course",
        "url": "https://example.com/course",
        "utm": "utm_source=playerstack&utm_medium=video"
      },
      "showReplay": true
    }
  }'
>
</player-stack>

Config

config.ctaEnd:

FieldTypeDescription
enabledbooleanPlugin is a no-op unless true
titlestring?Heading text inside the overlay
htmlstring?HTML filtered through core sanitizeHtml before rendering (see rules below)
button.labelstringVisible button text
button.urlstringDestination URL
button.utmstring?Query string appended to URL (e.g. utm_source=...)
showReplayboolean?Render a “Replay” button that re-plays the video and dismisses the overlay

Events

NamePayloadWhen
cta:click{ label: string, url: string }User clicks the CTA button
cta:replayundefinedUser clicks the replay button
ctx.events.on("cta:click", ({ label, url }) => {
  navigator.sendBeacon(
    "/api/track",
    JSON.stringify({
      event: "cta_click",
      label,
      url,
    }),
  );
});

Styling

The overlay uses CSS variables you can override:

Use controls-policy to set these per-player, or define them globally in your stylesheet.

HTML rendering rules

html passes through core’s sanitizeHtml before the resulting fragment is assigned to innerHTML.

This is a browser DOM-based rendering allowlist; without document, the helper returns an empty string. URL host policy and server-side validation remain the integrator’s responsibility.

Scrolling content

End cards are bounded by the player height and scroll inside their own overlay when content is too tall. Content stays centered when it fits and begins at the top when it overflows. Keyboard focus and pointer/touch scrolling do not move the player content.