Skip to content

Instantly share code, notes, and snippets.

@agehlot
Created July 11, 2021 15:28
Show Gist options
  • Save agehlot/26edaa8c183794642d452ce0d927b8a7 to your computer and use it in GitHub Desktop.
Save agehlot/26edaa8c183794642d452ce0d927b8a7 to your computer and use it in GitHub Desktop.
This is the sample html test page to verify how new user is being created in the Boxever? how new event can be trigger in the Boxever. Initially my event were not getting reflected there in Boxever user event section but later, when commented out pos value, it started working.
<html>
<head>
<script type="text/javascript">
// Define the Boxever queue
var _boxeverq = _boxeverq || [];
// Define the Boxever settings
var _boxever_settings = {
client_key: '<Replace your Clint_Key>', // Replace with your client key
target: 'https://api.boxever.com/v1.2', // Replace with your API target endpoint specific to your data center region
cookie_domain: 'boxever.mytest.com', // Replace with the top level cookie domain of the website that is being integrated e.g ".example.com" and not "www.example.com"
web_flow_target: 'https://d35vb5cccm4xzp.cloudfront.net',
//pointOfSale: 'mytest.com'
};
// Import the Boxever library asynchronously
(function() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'https://d1mj578wat5n4o.cloudfront.net/boxever-1.4.8.min.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
})();
function triggerEventViaPush()
{
// Place an anonymous function in the Boxever queue
_boxeverq.push(function() {
var searchEvent = {
"browser_id": Boxever.getID(),
"channel": "WEB",
"type": "SEARCH",
"language": "EN",
"currency": "AED",
"page": "test-arvind",
//"pos": window._boxever_settings.pointOfSale,
"product_name": "DUB-IND",
"product_type": "Push|DUB-IND|Business|Flex"
};
// Invoke event create
// (<event msg>, <callback function>, <format>)
Boxever.eventCreate(searchEvent, function(data){alert(JSON.stringify(data));}, 'json');
alert(window._boxever_settings.pointOfSale);
});
}
function sendDataToBoxever(eventType) {
var eventToSent = {
"channel": "WEB",
"type": eventType,
"pos": window._boxever_settings.pointOfSale,
"browser_id": Boxever.getID(),
"product_name": "DUB-IND",
"product_type": "DUB-IND|Economy|Flex" //"interactionID":"OOB_EXP",
//"interactionName": "EMAIL_BAR_DELAY"
};
Boxever.eventCreate(eventToSent, function(data){alert(JSON.stringify(data));}, 'json');
}
function addEventViaXmlHttp()
{
var xmlHttp = new XMLHttpRequest();
var searchEvent = {
"browser_id": Boxever.getID(),
"channel": "WEB",
"type": "SEARCH",
"language": "EN",
"currency": "AED",
"page": "/test-arvind",
"pos": window._boxever_settings.pointOfSale,
"product_name": "DUB-IND",
"product_type": "XmlHeep|DUB-IND|Economy|Flex"
};
var theUrl = 'https://api.boxever.com/v1.3/event/create.json?client_key=psfu6uh05hsr9c34rptlr06dn864cqrx&message=' + JSON.stringify(searchEvent)
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.send( null );
alert(JSON.stringify(xmlHttp.responseText));
}
</script>
</head>
<body>
</br>
Hello world!
</br></br>
<button onclick="triggerEventViaPush();">Trigger Boxever Event using Push</button>
</br></br>
<button onclick="sendDataToBoxever('SEARCH');">Trigger Boxever Event</button>
</br></br>
<button onclick="addEventViaXmlHttp();">Trigger Boxever Event using xml Http</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment