Script tag attributes
The SDK reads thesedata-* attributes from its own <script> tag when it executes.
string
required
Your publishable key (
cbh_pk_…). When present, the SDK initialises automatically. When absent, you must call init() yourself.string
Override the API base URL. Defaults to
https://sdk.cashbackhive.com/v1. Only needed for Cashback Hive-provided staging environments.boolean attribute
Log SDK activity to the console with a
[CashbackHive] prefix. The attribute’s presence enables it.Manual initialisation
If you omitdata-key, initialise the SDK yourself. This is useful when the key comes from a runtime config, or you need to register an on("ready") listener before initialisation.
CashbackHive.init(options)
string
required
Your publishable key. Throws
[CashbackHive] init requires a publishable key if missing.string
default:"https://sdk.cashbackhive.com/v1"
API base URL. A trailing slash is stripped.
boolean
default:"false"
Enable mock mode.
boolean
default:"false"
Enable debug logging.
init() runs once. Subsequent calls are ignored and, in debug mode, log init() called twice; ignoring. The cbh:ready event and onCashbackHiveReady callback fire after manual init() just as they do with auto-initialisation.Instance properties
string
The SDK version, e.g.
"0.1.0".boolean
true after init() has run (automatically or manually). Use this to check whether cbh:ready has already fired.Promise<void>
Resolves once
init() completes. Never rejects.Global hooks
CashbackHiveSdk
The SDK instance. Assigned as soon as
sdk.js executes, before initialisation.(sdk) => void
Optional callback you define. Called with the SDK instance after initialisation, immediately after the
cbh:ready event is dispatched.Analytics beacons
The SDK sends lightweight analytics events toPOST /v1/events so Cashback Hive can report on integration health. They’re fire-and-forget (keepalive: true, errors swallowed) and contain no personal data beyond what’s listed.
In mock mode, beacons are logged (in debug mode) instead of sent.