Sell tickets on your website
A ticket button, a single show card, or a whole ticket picker on your own page, with checkout opening on top of it.
1Choose a widget
There are seven, from a link you already have to your whole box office. Add the script once per page, anywhere in it, however many widgets the page has:
<script src="https://cocoscout.com/tickets/embed.js" async></script>
Then put a widget where it goes. Write it with your box office's address and the show's (both are in the show's ticket page link), or take embed_html from the API: every show and production has one, the single show card unless you add ?embed_view=dates or another view.
The first four are drawn right in your page, in your site's font, and take your colors through CSS (step 3). The last three are drawn by CocoScout in a frame, in the colors you set for your ticket pages, and the frame grows to fit.
Your own link
data-view="link"Keep the button you already have. embed.js leaves its look alone and opens tickets over your page when it's clicked. Any link to a CocoScout ticket page works, a short link included, so it needs no data-event. Without JavaScript it's still an ordinary link.
Late Night Sketch · Sat, Dec 12 · 7:30 PM
Get seats<a href="https://cocoscout.com/t/K7M2P/dec-12" data-cocoscout-tickets="the-basement" data-view="link" class="your-own-button">Get seats</a>
Single show card
data-view="single" DefaultOne date, its time, and a button: the soonest date on sale, or the one data-date names. When that show starts, the card moves on to the next date by itself. A sold-out date says so and offers the next date with seats. It has no heading unless you add one with data-heading. This is what you get when you leave out data-view; data-view="next" works too.
<div data-cocoscout-tickets="the-basement" data-event="late-night-sketch"></div>
Dates list
data-view="dates"Upcoming dates in a short list, each with a button that opens checkout on that date. It shows five, then a link to the rest; data-limit changes how many.
<div data-cocoscout-tickets="the-basement" data-event="late-night-sketch" data-view="dates" data-limit="5"></div>
Tickets for one date
data-view="tickets"One date's ticket types, each price with what's added to it, a quantity for each, the total, and a Checkout button. No date picker, so it suits a page for a single night. Checkout opens over your page with the seats already held.
<div data-cocoscout-tickets="the-basement" data-event="late-night-sketch" data-date="dec-12" data-view="tickets"></div>
Full picker
data-view="full"The show's name, its dates, and the chosen date's tickets. Good for a page that's all about one show. It used to be called card, and data-view="card" still works.
<div data-cocoscout-tickets="the-basement" data-event="late-night-sketch" data-view="full"></div>
Whole box office
data-view="box-office"Every show you have on sale, soonest first.
<div data-cocoscout-tickets="the-basement" data-view="box-office"></div>
Other settings
| Attribute | Widgets | What it does |
|---|---|---|
| data-view | all | link, button, single (the default), dates, tickets, full, or box-office. With no data-event and no data-view, the whole box office. |
| data-event | all but link and box-office | The show's address, like late-night-sketch, or one date's address. Both are in your ticket page links. |
| data-date | button, single, tickets, full | One date, written dec-12. Without it, the next date on sale. |
| data-limit | dates | How many dates before the link to the rest: 5 unless you change it. |
| data-checkout="page" | all | Opens checkout in a new tab on CocoScout instead of over your page. |
| data-code | all but box-office | A discount or access code, applied when checkout opens. |
2Change the words
Every piece of text a widget shows can be changed with an attribute. Set one to an empty string to hide that line.
| Attribute | Widgets | Unless you change it | What it is |
|---|---|---|---|
| data-label | button, single, dates, tickets | "Buy tickets"; "Tickets" on each date in dates; "Checkout" in tickets | The button's words. On button, the element's own text works too. |
| data-heading | single, dates, tickets | None in single; "Upcoming shows" in dates; the date in tickets | The small heading above the card, the list, or the tickets. The single show card has one only when you add it. |
| data-sold-out-label | button, single, dates | "Sold out" | What a sold-out date shows in place of its button. |
| data-next-date-label | single | "Next date:" | Before the next date with seats, when the card's date is sold out. |
| data-empty-text | single, dates | "No shows on sale right now." | What shows when nothing is on sale. Empty hides the whole widget. |
| data-more-label | dates | "4 more dates" | The link under a cut-off list. {count} is the number of dates left. |
| data-date-style | single, dates | long in single, short in dates | long is "Saturday, December 5, 2026"; short is "Sat, Dec 5". |
<div data-cocoscout-tickets="the-basement" data-event="late-night-sketch" data-heading="Next show" data-label="Get tickets"></div>
3Match your site
Every widget starts in the colors you set for your ticket pages. The four drawn in your page also use your site's font, and until you set any page colors, everything but their buttons follows your site's own text color, so they sit on a dark page or a light one.
To give one widget its own colors, add the same four your ticket page settings have. They're six-digit hex colors, with or without the #. They replace the settings' colors for that widget only, including the checkout it opens, so the whole purchase matches.
| Attribute | In your page | In a frame and in checkout |
|---|---|---|
| data-button-color | Buttons. Their words are white or near-black, whichever reads better. | Buttons, links, and the chosen date. |
| data-background-color | Behind the single show card. | The page behind the ticket boxes. |
| data-heading-color | The date. | The show's name and the date above the tickets. |
| data-text-color | Times, the heading, "Sold out", and the lines between dates. | Words on the page behind the ticket boxes. |
<div data-cocoscout-tickets="the-basement" data-event="late-night-sketch" data-view="tickets" data-button-color="#7c1714" data-background-color="#ffffff"></div>
For finer control of the four in your page, set these CSS custom properties on the widget, or on :root. They win over the colors above:
[data-cocoscout-tickets] { --cocoscout-button-bg: #ffffff; /* buttons */ --cocoscout-button-fg: #000000; /* their words */ --cocoscout-radius: 0; /* buttons and the card's corners */ --cocoscout-card-bg: #181818; /* behind the single show card */ --cocoscout-heading: #ffffff; /* the dates */ --cocoscout-border: #3a3a3a; /* the card's edge, and lines between dates */ --cocoscout-muted: #a8a8a8; /* headings, times, and "Sold out" */}
For anything further, each piece has a class: .cocoscout-button, .cocoscout-single, .cocoscout-dates, .cocoscout-heading, .cocoscout-date, .cocoscout-time, and .cocoscout-sold-out. Your own rules win over the widget's.
4Say thanks your way
When the buyer pays, your page gets a cocoscout:paid event with the order code and ticket count. Buyer names and emails never pass through your page; read the order with the API if you need them. Closing the checkout sends cocoscout:closed.
document.addEventListener("cocoscout:paid", (event) => { // { order_code: "K7Q2", tickets: 2 } showThanks(`You're in! Order ${event.detail.order_code}.`);});
5Or draw your own ticket picker
List the dates with GET /v1/shows?status=on_sale, hold the seats from your server with POST /v1/checkouts, and open that checkout over your page. Keep your key on your server; the checkout token is safe in the browser.
// On your serverconst res = await fetch("https://api.cocoscout.com/v1/checkouts", { method: "POST", headers: { Authorization: `Bearer ${process.env.COCOSCOUT_KEY}`, "Content-Type": "application/json", "Idempotency-Key": crypto.randomUUID() }, body: JSON.stringify({ show_id: 4812, tickets: [{ ticket_type_id: 912, quantity: 2 }] })});const { checkout_token } = await res.json();// In the browser, with embed.js on the pageCocoScout.checkout(checkout_token); // seats are held for 10 minutes