Skip to content

Commit 74260d5

Browse files
authored
Integration snippet image replaced.
Integration snippet image replaced with copyable code snippet.
1 parent 41b9b92 commit 74260d5

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

README.md

+37-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,43 @@ or
4040

4141
Link to the script and call helper methods based on what you want to track: sessions, views, clicks, custom events, user data, etc. More information is available at [https://support.count.ly/hc/en-us/articles/360037441932-Web-analytics-JavaScript-](https://support.count.ly/hc/en-us/articles/360037441932-Web-analytics-JavaScript-)
4242

43-
![Using Countly web SDK in your web page](https://count.ly/github/countly-web-sdk.png)
43+
<script type='text/javascript'>
44+
// Some default pre init
45+
var Countly = Countly || {};
46+
Countly.q = Countly.q || [];
47+
48+
// Provide your app key that you retrieved from Countly dashboard
49+
Countly.app_key = "YOUR_APP_KEY";
50+
51+
// Provide your server IP or name. Use try.count.ly or us-try.count.ly
52+
// or asia-try.count.ly for EE trial server.
53+
// If you use your own server, make sure you have https enabled if you use
54+
// https below.
55+
Countly.url = "https://yourdomain.com";
56+
57+
// Start pushing function calls to queue
58+
// Track sessions automatically (recommended)
59+
Countly.q.push(['track_sessions']);
60+
61+
//track web page views automatically (recommended)
62+
Countly.q.push(['track_pageview']);
63+
64+
// Uncomment the following line to track web heatmaps (Enterprise Edition)
65+
// Countly.q.push(['track_clicks']);
66+
67+
// Uncomment the following line to track web scrollmaps (Enterprise Edition)
68+
// Countly.q.push(['track_scrolls']);
69+
70+
// Load Countly script asynchronously
71+
(function() {
72+
var cly = document.createElement('script'); cly.type = 'text/javascript';
73+
cly.async = true;
74+
// Enter url of script here (see below for other option)
75+
cly.src = 'https://cdn.jsdelivr.net/npm/countly-sdk-web@latest/lib/countly.min.js'; // Use any of the 3 methods to get Countly Web Analytics SDK here
76+
cly.onload = function(){Countly.init()};
77+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(cly, s);
78+
})();
79+
</script>
4480

4581
Countly Web SDK has JSDoc3 compatible comments and you can generate documentation by running `npm run-script docs` or access online version at [https://countly.github.io/countly-sdk-web/](https://countly.github.io/countly-sdk-web/)
4682

0 commit comments

Comments
 (0)