countly-sdk-web
Version:
Countly Web SDK
85 lines (70 loc) • 2.44 kB
HTML
<html>
<head>
<!-- Page styling here -->
<link rel='stylesheet' type='text/css' href='./style/style.css'>
<p><a href='https://countly.com/'>Countly</a></p>
<!--Countly script-->
<script type='text/javascript' src='../lib/countly.js'></script>
<script type='text/javascript'>
Countly = Countly || {};
Countly.q = Countly.q || [];
//initializing first instance, which will be global Countly
const COUNTLY_SERVER_KEY = "https://your.server.ly";
const COUNTLY_APP_KEY = "YOUR_APP_KEY";
if (COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly") {
console.warn("Please do not use default set of app key and server url")
}
// initializing countly with params
Countly.init({
app_key: COUNTLY_APP_KEY,
url: COUNTLY_SERVER_KEY, //your server goes here
debug: true
})
//report event to first app
Countly.add_event({
key: "first_app"
});
//initialize second instance for another app synchronously
const COUNTLY_SERVER_KEY2 = "https://your.server.ly";
const COUNTLY_APP_KEY2 = "YOUR_APP_KEY2";
if (COUNTLY_APP_KEY2 === "YOUR_APP_KEY2" || COUNTLY_SERVER_KEY2 === "https://your.server.ly") {
console.warn("Please do not use default set of app key and server url")
}
// initializing countly with params
var Countly2 = Countly.init({
app_key: COUNTLY_APP_KEY2,
url: COUNTLY_SERVER_KEY2, //your server goes here
debug: true
});
//report event to second app
Countly2.add_event({
key: "second_app"
});
const COUNTLY_SERVER_KEY3 = "https://your.server.ly";
const COUNTLY_APP_KEY3 = "YOUR_APP_KEY3";
if (COUNTLY_APP_KEY3 === "YOUR_APP_KEY3" || COUNTLY_SERVER_KEY2 === "https://your.server.ly") {
console.warn("Please do not use default set of app key and server url")
}
//initialize third instance for another app asynchronously
Countly.q.push(["init", {
app_key: COUNTLY_APP_KEY3, //must have different APP key
url: COUNTLY_SERVER_KEY3, //your server goes here
debug: true
}])
//report event to third app asynchronously by passing app key as first arg
Countly.q.push([COUNTLY_APP_KEY3, "add_event", {
key: "third_app"
}]);
</script>
</head>
<body>
<!-- Header, banner etc. Top part of your site -->
<div id="header">
<h1>Multi Instancing</h1>
<img id="logo" src="./images/logo.png">
</div>
<center>
<img src="./images/team_countly.jpg" id="wallpaper" />
</center>
</body>
</html>