Promo code with copy button

An offer banner with a dashed coupon box, a button that copies the code to the clipboard and a shop button that reports its click to analytics.

copydata-copytrackdata-trackpromocoupondiscountofferclipboardanalytics

About this block

data-copy="TEXT" on a button copies that text to the clipboard when clicked and sets data-copied for two seconds, which the button's own classes use to show Copied. data-track="ga4:event_name" on a link sends that event to your analytics when it is clicked.

How to customize it

  • Change the code in both places: the visible text and the data-copy value.
  • data-track works with ga4:, gtm:, plausible: and meta: prefixes. The matching analytics snippet must be installed for the site (Integrations).
  • group-data-[copied]: classes on the button's children switch the icon and label while the copied flag is set.

Browse other blocks

Same library cards — preview live and grab the code from any block.

View full library