window object, using the window.Candu object.
Candu.init
Candu.init a method used to initialize Candu.
At a high level, Candu.init performs the following actions:
- Initialize an instance of Candu.
- Talks to Candu servers to get a user’s state.
Candu.init takes only one parameter, an init object. This is the same object that you pass in when you install the script tag.
Here is how to call Candu.init:
Candu.getEventing
Candu.getEventing returns a javascript object that you can use to send us additional eventing data, such as button clicks or page views. It’s useful in case you want to track events that occur outside of Candu.
Candu.getEventing takes no parameters, and returns an object with the following interface:
Candu.eventing:
Candu.tearDown
Candu.tearDown is used to destroy and teardown a client. This can be useful to:
- Remove a users session and Candu content when a user logs out of your page.
- Temporarily hide all Candu content during critical user flows (checkout processes, system maintenance notifications, native modals, etc.).
- Free up browser resources in case you don’t need Candu anymore on a page.
Candu.tearDown takes no parameters.
Here is how to call Candu.tearDown:
Candu.tearDown is not necessary if a logout reloads the page.
Note: After callingtearDown(), you’ll need to callCandu.init()again to restore Candu functionality within the same browser session.
Candu.getMembership
This call returns the Segment IDs that the current customer belongs to in Candu Segmentation. Segment IDs correspond with individual segments configured within the Candu dashboard. This can be used to determine if a customer falls in to a specific Candu Segment to provide supporting content.TypeScript
TypeScript
Candu.refreshMembership
This call is used to force the Candu client to reload Candu Segmentation.Candu.init, typically on the next page load.
Triggering Content Programmatically
For most use cases we recommend placing content with the Candu Extension , but for advanced use cases you may need to trigger content programmatically. You’ll need to implement any conditional logic when setting up the trigger on your side, as they do not apply any placements, i.e. URL rules you have set up in Candu. Trigger content will still abide by Segmentation rules. As a best practice, we recommend removing the trigger snippet from your code when you no longer want the content to be triggered as triggering content programmatically bypasses publish state.Candu.renderContent
To render a piece of Inline Content. You can target either an element or a CSS selectorCandu.triggerModal
Used to trigger Overlays, pop-ups and slide-outs. On-screen position is configured within the Candu Editor. Note: Modals can also be triggered on page load guide or from Candu content guide.Typescript