Install zoovu-sdk.js
To install zoovu-sdk.js add the code below in the <head> of the page, replace the <ZOOVU_SDK_BASE_URL> placeholder with a value from the table below, depending on the environment where the assistant lives.
<!-- Zoovu SDK (zoovu-sdk.js) -->
<script async src="<ZOOVU_SDK_BASE_URL>/zoovu-sdk-latest.min.js"></script>
<script>ZoovuSDK = window.ZoovuSDK || { init: function () { ZoovuSDK.q = ZoovuSDK.q || [], ZoovuSDK.q.push(arguments) }, assistantInit: function () { ZoovuSDK.aq = ZoovuSDK.aq || [], ZoovuSDK.aq.push(arguments) } };</script>
env | ZOOVU_SDK_BASE_URL |
---|---|
qa | https://staging-orca-cdn.zoovu.com/core-js/zoovu-sdk |
stg | https://staging-orca-cdn.zoovu.com/core-js/zoovu-sdk |
orca | https://orca-cdn.zoovu.com/core-js/zoovu-sdk |
barracuda | https://barracuda-cdn.zoovu.com/core-js/zoovu-sdk |
Initialization
If the script is not loaded yet use syntax:
ZoovuSDK.init(function () {
// add code independent of the assistant presence
});
ZoovuSDK.init
is triggered when Zoovu SDK is loaded and ready to use, it is useful for things not specifically related to assistant (storage
).
In case you need to interact with the assistant (events
, dataLayer
) you may want to use ZoovuSDK.assistantInit
that is triggered when the assistant is loaded and ready to use.
ZoovuSDK.assistantInit(function() {
// add code dependent of the assistant presence
}, <ASSISTANT_CODE>) // `ASSISTANT_CODE` is optional, useful for multi assistants cases.
Specify assistant-code
For assistants related methods e. g. ZoovuSDK.assistantInit
it is possible to specify an assistant-code when registering an event-handler.
This is for advanced use-cases where:
- you have multiple assistants on the same page
- you want to respond differently to events generated by these assistants
Do not specify the assistant-code if it is not necessary. When an assistant-code is specified, events triggered by other assistants would not be captured. You could have other assistants when you e.g. introduce an A/B-test or launcher to your page instead of a direct assistant integration.