Oct8ne triggers offer the possibility of interacting with the visitor when specific circumstances previously defined in the ‘Triggers’ section of the Oct8ne dashboard (for example: time on the page or a specific URL address) occur.
But sometimes these conditions are not enough to meet very specific cases that can occur in some web pages and, for this reason, Oct8ne's custom triggers are born. Thanks to them , there will be no more obstacles when defining the conditions to trigger the chat. We will have absolute freedom to choose the ideal moment when we want to start a conversation with the visitor.
But what do you need to create a custom trigger?
Follow the steps below to set it up in just a few minutes. It is advisable that the implementation is carried out by your IT team:
1. Generate the dynamic code that suits your purpose:
The first thing you need is to be clear about the conditions that, if met, will open the Oct8ne chat and have control over them through Javascript variables in the different pages of our website where we want the trigger to act, assigning values to each one, according to the behaviour that corresponds to the user's interactions.
Let's assume that we want the Oct8ne chat to open when the visitor exceeds a cart value of 100€ and is in the ‘Men’ product category. This would involve creating a variable that takes the numerical value corresponding to the sum of the prices of all the products that the user has in his cart and another variable of type text that takes the name of the product category in which the user is at that moment.
The final objective is that the variables that we manage end up appearing as another parameter in the Oct8ne code that is attached to our web page, in the property oct8ne.customData:
<script type="text/javascript">
var oct8ne = document.createElement("script");
oct8ne.type = "text/javascript";
...
oct8ne.customData={
valorCarro:100,
categoría:"Hogar"
}
...
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(oct8ne, s);
</script>
<script type="text/javascript"> var oct8ne = document.createElement("script"); oct8ne.type = "text/javascript"; ... oct8ne.customData={ valorCarro:100, categoría:"Hogar" } ... var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(oct8ne, s); </script>
|
2. Create a trigger in the Oct8ne Dashboard according to the desired value of our variables:
When we have finished with the control of the variables, we must go to the Oct8ne dashboard and create a new trigger that contains, at least, a custom condition (as shown in the dropdown in the image).
We must fill these conditions with the same name that we have given in the Oct8ne code and the comparison with the value we want, but it is very important that this corresponds to the type of data, i.e. you can not declare that a string is greater than another because it will not work.
Nested properties or sub-objects are not allowed to be evaluated, for example, if it is defined in the conditions that the property ‘cart.value’ is greater than 100, what will be evaluated will be the property oct8ne.customData[‘cart.value’], NOT as the value property inside the cart: oct8ne.customData.cart.value.
Some examples of customised conditions, including the case of the previous step:
To compare text values (e.g. category name) you can use the comparators Contains, Does not contain, Starts with, Ends with, Does not start with, Does not end with; while for numeric values you can use Equal to, Greater than, Less than.
You can also check if the parameter is simply added or not, regardless of its value with Exists and Does not exist.
How to update the value of variables in real time
The value of the properties defined as conditions is normally evaluated when the page is loaded and does not change until the page is changed or reloaded.
In the case that we want to update a value from an event that has happened on the page and evaluate it to check if a trigger has to be launched, we can create a call to the following method:
oct8ne.updateTriggerValue (nombrePropiedad, nuevoValor)
For example, if we have defined the variable oct8ne.customData.cartValue=0, and the visitor adds a product to the cart using Ajax, we can call the above method in the following way oct8ne.updateTriggerValue (‘cartValue’, 150).
This call will update its value to oct8ne.customData.cartValue=150, and will re-evaluate the triggers in case one should be triggered when modified.