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.comorhttp://localhost:3000) added to the property’s allowed origins. API calls from any other origin are rejected. See Keys and allowed origins.
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 If your code might run after the SDK has already initialised (for example a lazily mounted component), check
cbh:ready event on window once it has initialised. The SDK instance is on event.detail.sdk (and also on window.CashbackHive).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. See the Activate widget for a complete sign-in UI.
auth.signIn() opens the Cashback Hive sign-in window and resolves with the member once they’re done.Check it worked
Open your browser’s developer tools on an allowed origin:- Network tab — you should see
sdk.js(200), aPOST …/v1/eventsbeacon, andGET …/v1/offers(200). - Console —
window.CashbackHive.initializedshould betrue.
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.