NOTE: This tutorial requires basic knowledge of JavaScript coding.
With a small script and help from the ipinfo.io API (free service from geoip) it's possible to configure Cliengo so that is only enabled for visitors of certain countries by detecting the country IP address from the visitors that land in your website.
In the figure below, for instance, you can see how the source code would look so that the Chatbot is only shown to visitors from Argentina:
NOTA: Este tutorial requiere básicos conocimientos de programación en JavaScript.
Con un pequeño script y la ayuda de la API de ipinfo.io (servicio gratuito de geoip), es posible limitar la ejecución del chat de Cliengo de acuerdo al país de la IP del visitante.
Este es un ejemplo de código el chat para que sólo se muestre a visitantes ubicados en Argentina:
<script> function getAjax(url, success) { var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); xhr.open('GET', url); xhr.onreadystatechange = function() { if (xhr.readyState > 3 && xhr.status == 200) success(xhr.responseText); }; xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhr.send(); return xhr; } getAjax('https://ipinfo.io/json', function(data) { if (data.country = "AR") { // Es user de Argentina <!-- REPLACE CLIENGO INSTALLATION CODE HERE --> (function() { var ldk = document.createElement('script'); ldk.type = 'text/javascript'; ldk.async = true; ldk.src = 'https://s.cliengo.com/weboptimizer/ID_EMPRESA_CLIENGO/ID_WEBSITE_CLIENGO.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ldk, s); })(); <!-- RREPLACE CLIENGO INSTALLATION CODE HERE --> } else { console.log("No es user de Argentina"); } }); </script>
IMPORTANT: Make sure to replace the installation code where it's indicated.
Comments
0 comments
Article is closed for comments.