The standard way of loading the Ocavu Web SDK on a webpage is to reference the script just before the close of the body:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!-- Page content -->
<script src="https://view.ocavu.com/YOUR_TOKEN_HERE/ocavu.min.js"></script>
</body>
</html>
Can I load the Ocavu Web SDK asynchronously?
Yes! Loading the Ocavu Web SDK while declaring the async attribute is supported:
<script async src="https://view.ocavu.com/YOUR_TOKEN_HERE/ocavu.min.js"></script>
Another supported use case is injection of the script after the page has loaded:
<script>
window.addEventListener('DOMContentLoaded', function () {
var ocavuScript = document.createElement('script');
ocavuScript.src = 'https://view.ocavu.com/YOUR_TOKEN_HERE/ocavu.min.js';
document.body.appendChild(ocavuScript);
});
</script>
Can I load the Ocavu Web SDK conditionally?
Yes, there are two main strategies:
- Use a tool such as Google Tag Manager to dynamically inject the Ocavu Web SDK only on the pages that need it.
- Set up your websites template system to only load the Ocavu Web SDK on a specific subset of pages.