Skip to main content
This guide gets cashback offers rendering on a page. It uses plain HTML so it applies to any stack; see Installation for framework-specific versions.

Before you start

You need:
  • A publishable key for your property. It starts with cbh_pk_ and is shown in the publisher portal.
  • Your site’s origin (for example https://www.example.com or http://localhost:3000) added to the property’s allowed origins. API calls from any other origin are rejected. See Keys and allowed origins.
Only ever put the publishable key in browser code. Never add a secret key to a web page, a NEXT_PUBLIC_* variable, or a tag manager.
1

Add the script tag

Place the tag anywhere in your HTML. The data-key attribute is what tells the SDK to initialise.
2

Wait for cbh:ready

The SDK dispatches a cbh:ready event on window once it has initialised. The SDK instance is on event.detail.sdk (and also on window.CashbackHive).
If your code might run after the SDK has already initialised (for example a lazily mounted component), check window.CashbackHive?.initialized first. See Lifecycle for all the options.
3

List offers

offers.list() returns the offers available to your property.
openOffer() opens the retailer in a new tab through a tracked link so the purchase is attributed to your property.
4

Let members sign in (optional)

Members earn cashback on their purchases. auth.signIn() opens the Cashback Hive sign-in window and resolves with the member once they’re done.
See the Activate widget for a complete sign-in UI.

Check it worked

Open your browser’s developer tools on an allowed origin:
  • Network tab — you should see sdk.js (200), a POST …/v1/events beacon, and GET …/v1/offers (200).
  • Console — window.CashbackHive.initialized should be true.
If offers.list() rejects with a 403, the current origin isn’t on the property’s allowed list. See Troubleshooting.

Next steps

Install in your framework

Next.js, React, plain HTML and Google Tag Manager.

Build the widgets

Reference implementations of the Offers and Activate widgets.

Local development

Use mock mode to develop without a network or a signed-in member.

API reference

Every method, option and event.