Claspo’s JavaScript API allows you to personalize widgets using JavaScript variables. You can dynamically pass data from your website directly into Claspo and leverage this information in your widgets. Practically, this enables you to personalize widgets using data such as the visitor’s cart value, subscription status, loyalty tier, and more.
How to set JavaScript variables on your website
To use JavaScript variables in Claspo, you first need to send the data from your website to Claspo using our JavaScript API. This requires adding a small script to your website or tag manager.
The general format is:
<script>
claspo('addVariables', { variableName: value });
</script>
For example:
<script>
claspo('addVariables', { subscribed: false });
</script>
You can add multiple variables at once, like:
<script>
claspo('addVariables', {
user_age: 25,
user_status: 'vip'
});
</script>
Where to place the script:
Directly into your website's code (after the Claspo base script is loaded).
Or via Google Tag Manager using a Custom HTML Tag. Read more