Features
Live values
Settings your code reads from Beacon, like a plan limit, a banner or a price, that you change in the dashboard without a release. Different visitors can get different values.
Create one
In Live values, choose New value: a name, a key for your code, a type (text, number, true/false or JSON) and the value for everyone. Then add rules for who gets something else.
In your code
const limit = await beacon('value', 'free-project-limit', 3);
if (projects.length >= limit) {
showUpgradePrompt();
}beacon('value', key, fallback) returns a promise of this visitor's value. The fallback is what you get if the key doesn't exist or Beacon can't be reached, so your site always has something sensible. JSON values arrive as objects or lists, ready to use:
const banner = await beacon('value', 'launch-banner', null);
if (banner) {
showBanner(banner.text, banner.link); // { "text": "Beacon 2 is here", "link": "/blog/launch" }
}Who gets what
Rules are checked in order and the first one that matches wins; everyone else gets the default. Change the order with the arrows in the dashboard.
| Rule | For example | Checked |
|---|---|---|
| In a cohort | In cohort Regulars gets 10 | Asks Beacon once per visit |
| A property | plan is team or business gets 25 | In the browser, from beacon('set') |
| Signed in | Signed in gets true | In the browser, from beacon('identify') |
| On a page | On pages starting /beta gets 50 | In the browser |
| On a device | On mobile gets 2 | In the browser |
| A random share | 20% of visitors gets 5 | In the browser; a visitor keeps their answer |
| Everyone | Everyone gets 4 | In the browser |
Cohorts are worked out from what visitors did, which only Beacon knows, so when the tag reaches a cohort rule it asks Beacon which cohorts this visitor is in. It does that once per visit, and only if a value you read has a cohort rule; everything else is instant.
Changing a value
Save and publish reaches sites within a couple of minutes: the tag reads Beacon's settings once per page and keeps them for a minute. Every change is kept in the value's history, with who made it and what changed, and Restore puts any earlier version back.
On your server
To use a value before the page reaches the browser, ask Beacon for every value worked out for one visitor. All parameters but key are optional; rules needing a missing one don't match.
curl "https://beacon.endevre.com/v1/values?key=B-XXXXXX&visitor=VISITOR_ID&user=USER_ID&props=%7B%22plan%22%3A%22team%22%7D&path=/pricing&device=mobile"
{ "values": { "free-project-limit": 25, "launch-banner": { "text": "Beacon 2 is here" } } }visitor is Beacon's visitor ID (the _bk cookie), user your user ID, props a JSON object like the one you pass to beacon('set'), and device one of desktop, mobile or tablet.