Countly Web SDK: Track site accesses and errors the Countly API

Recommend this page to a friend!
  Info   View files Documentation   View files View files (88)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2022-04-29 (28 days ago) RSS 2.0 feedNot enough user ratingsTotal: 85 All time: 444 This week: 4Up
Version License JavaScript version Categories
countly-web-sdk 1.0Custom (specified...1.0AJAX, Web services
Collaborate with this project Author

Countly Web SDK - github.com

Description

This package track site accesses and errors the Countly API.

It can track several types of statistics and events like user sessions, clicks, form submissions, and JavaScript errors.

The events are reported to the Countly server using AJAX requests that can be sent synchronously or asynchronously to avoid page loading delays.

Innovation Award
JavaScript Programming Innovation award winner
August 2015
Winner
Countly is a service that can track several types of user access statistics and action events the users perform on pages.

This package uses the Country API to record useful information for the developer about important events like clicks on the page, form submissions or even JavaScript errors.

Manuel Lemos
Picture of Arturs Sosins
  Performance   Level  
Name: Arturs Sosins <contact>
Classes: 51 packages by
Country: Latvia Latvia
Age: 34
All time rank: 1
Week rank: 3 Down1 in Latvia Latvia Equal
Innovation award
Innovation award
Nominee: 8x

Winner: 6x

Details

Countly Web SDK

Codacy Badge npm version Inline docs ![](https://www.jsdelivr.com/package/npm/countly-sdk-web)

What is Countly?

Countly is a product analytics solution and innovation enabler that helps teams track product performance and customer journey and behavior across mobile, web, and desktop applications. Ensuring privacy by design, Countly allows you to innovate and enhance your products to provide personalized and customized customer experiences, and meet key business and revenue goals.

Track, measure, and take action - all without leaving Countly.

Implementing Countly SDK in your web pages

There are 3 ways to get Countly SDK.

1. Available with Countly server

Since Countly server 16.02, Countly Web SDK is available in your Countly server installation in countly/frontend/express/public/sdk/web/countly.min.js which should be available through URL as https://yourserver.com/sdk/web/countly.min.js

2. Installation using package managers

bower install countly-sdk-web

or

npm install countly-sdk-web

or

yarn add countly-sdk-web

3. Use a CDN (content delivery network)

Countly web SDK is available on CDNJS. Use either

https://cdnjs.cloudflare.com/ajax/libs/countly-sdk-web/22.02.0/countly.min.js

or

https://cdn.jsdelivr.net/npm/countly-sdk-web@latest/lib/countly.min.js

How to use Countly Web SDK?

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-

<script type='text/javascript'>
// Some default pre init
var Countly = Countly || {};
Countly.q = Countly.q || [];

// Provide your app key that you retrieved from Countly dashboard
Countly.app_key = "YOUR_APP_KEY";

// Provide your server IP or name. Use try.count.ly or us-try.count.ly 
// or asia-try.count.ly for EE trial server.
// If you use your own server, make sure you have https enabled if you use
// https below.
Countly.url = "https://yourdomain.com"; 

// Start pushing function calls to queue
// Track sessions automatically (recommended)
Countly.q.push(['track_sessions']);

//track web page views automatically (recommended)
Countly.q.push(['track_pageview']);

// Uncomment the following line to track web heatmaps (Enterprise Edition)
// Countly.q.push(['track_clicks']);

// Uncomment the following line to track web scrollmaps (Enterprise Edition)
// Countly.q.push(['track_scrolls']);

// Load Countly script asynchronously
(function() {
    var cly = document.createElement('script'); cly.type = 'text/javascript'; 
    cly.async = true;
    // Enter url of script here (see below for other option)
    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
    cly.onload = function(){Countly.init()};
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(cly, s);
})();
</script>

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/

Security

Security is very important to us. If you discover any issue regarding security, please disclose the information responsibly by sending an email to security@count.ly and not by creating a GitHub issue.

Other Github resources

Check Countly Community Edition source code here:

There are also other Countly SDK repositories below:

How can I help you with your efforts?

Glad you asked. We need ideas, feedbacks and constructive comments. All your suggestions will be taken care with upmost importance. We are on Twitter and Facebook if you would like to keep up with our fast progress!

Badges

If you like Countly, why not use one of our badges and give a link back to us, so others know about this wonderful platform?

<a href="https://count.ly/f/badge" rel="nofollow"><img style="width:145px;height:60px" src="https://count.ly/badges/dark.svg?v2" alt="Countly - Product Analytics" /></a>

<a href="https://count.ly/f/badge" rel="nofollow"><img style="width:145px;height:60px" src="https://count.ly/badges/dark.svg" alt="Countly - Product Analytics" /></a>

<a href="https://count.ly/f/badge" rel="nofollow"><img style="width:145px;height:60px" src="https://count.ly/badges/light.svg?v2" alt="Countly - Product Analytics" /></a>

<a href="https://count.ly/f/badge" rel="nofollow"><img style="width:145px;height:60px" src="https://count.ly/badges/light.svg" alt="Countly - Product Analytics" /></a>

Support

For a public community support page, visit https://support.count.ly/hc/en-us/community/topics.

NPM

  Files folder image Files  
File Role Description
Files folder image.github (1 file, 1 directory)
Files folder imagecypress (1 file, 4 directories)
Files folder imageexamples (14 files, 3 directories)
Files folder imagelib (2 files)
Files folder imageplugin (2 directories)
Accessible without login Plain text file .eslintignore Data Auxiliary data
Plain text file .eslintrc.js Class Class source
Accessible without login Plain text file bower.json Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Example Example script
Accessible without login Plain text file cypress.json Data Auxiliary data
Accessible without login Plain text file generateDocs.sh Data Auxiliary data
Accessible without login Plain text file inch.json Data Auxiliary data
Accessible without login Plain text file jsdoc_conf.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file package.json Data npm support
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file SECURITY.md Data Auxiliary data
Plain text file webpack.config.js Class Class source

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (2 files)
  Accessible without login Plain text file dependabot.yml Data Auxiliary data

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file codeql-analysis.yml Data Auxiliary data
  Accessible without login Plain text file node.js.yml Data Auxiliary data

  Files folder image Files  /  cypress  
File Role Description
Files folder imagefixtures (1 file)
Files folder imageintegration (9 files)
Files folder imageplugins (1 file)
Files folder imagesupport (3 files)
  Plain text file .eslintrc.js Class Class source

  Files folder image Files  /  cypress  /  fixtures  
File Role Description
  Accessible without login Plain text file variables.json Data Auxiliary data

  Files folder image Files  /  cypress  /  integration  
File Role Description
  Accessible without login Plain text file consents.js Aux. Auxiliary script
  Accessible without login Plain text file device_id.js Aux. Auxiliary script
  Accessible without login Plain text file events.js Aux. Auxiliary script
  Accessible without login Plain text file internal_limits.js Aux. Auxiliary script
  Accessible without login Plain text file reponse_validation.js Aux. Auxiliary script
  Accessible without login Plain text file sessions.js Aux. Auxiliary script
  Accessible without login Plain text file user_details.js Aux. Auxiliary script
  Accessible without login Plain text file utm.js Aux. Auxiliary script
  Accessible without login Plain text file views.js Aux. Auxiliary script

  Files folder image Files  /  cypress  /  plugins  
File Role Description
  Plain text file index.js Class Class source

  Files folder image Files  /  cypress  /  support  
File Role Description
  Accessible without login Plain text file commands.js Aux. Auxiliary script
  Plain text file helper.js Class Class source
  Accessible without login Plain text file index.js Aux. Auxiliary script

  Files folder image Files  /  examples  
File Role Description
Files folder imagempa (2 files, 1 directory)
Files folder imagereact (3 files, 2 directories)
Files folder imagesymbolication (7 files, 2 directories)
  Accessible without login HTML file examples_feedback_widgets.html Doc. Documentation
  Accessible without login HTML file example_apm.html Doc. Documentation
  Accessible without login Plain text file example_async.html Doc. Documentation
  Accessible without login HTML file example_fb.html Data Auxiliary data
  Accessible without login HTML file example_formdata.html Data Auxiliary data
  Accessible without login HTML file example_ga_adapter.html Doc. Documentation
  Accessible without login HTML file example_gdpr.html Doc. Documentation
  Accessible without login Plain text file example_helpers.html Doc. Documentation
  Accessible without login HTML file example_internal_limits.html Doc. Documentation
  Accessible without login HTML file example_multiple_instances.html Doc. Documentation
  Accessible without login HTML file example_opt_out.html Doc. Documentation
  Accessible without login HTML file example_rating_widgets.html Doc. Documentation
  Accessible without login HTML file example_remote_config.html Doc. Documentation
  Accessible without login Plain text file example_sync.html Doc. Documentation

  Files folder image Files  /  examples  /  mpa  
File Role Description
Files folder imageboomerang (2 files)
  Accessible without login HTML file index.html Doc. Documentation
  Accessible without login Image file team_countly.jpg Data Auxiliary data

  Files folder image Files  /  examples  /  mpa  /  boomerang  
File Role Description
  Plain text file boomerang-1.0.0.js Class Class source
  Accessible without login Plain text file countly_boomerang.js Example Example script

  Files folder image Files  /  examples  /  react  
File Role Description
Files folder imagepublic (4 files)
Files folder imagesrc (10 files, 1 directory)
  Accessible without login Plain text file package-lock.json Data Auxiliary data
  Accessible without login Plain text file package.json Data Auxiliary data
  Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  examples  /  react  /  public  
File Role Description
  Accessible without login Image file favicon.ico Data Auxiliary data
  Accessible without login HTML file index.html Doc. Documentation
  Accessible without login Plain text file manifest.json Data Auxiliary data
  Accessible without login Plain text file robots.txt Doc. Documentation

  Files folder image Files  /  examples  /  react  /  src  
File Role Description
Files folder imageComponents (6 files)
  Accessible without login Plain text file App-WithEffect.js Aux. Auxiliary script
  Plain text file App-WithRouter.js Class Class source
  Accessible without login Plain text file App.test.js Aux. Auxiliary script
  Plain text file ErrorBoundary.js Class Class source
  Accessible without login Plain text file index.css Data Auxiliary data
  Accessible without login Plain text file index.js Aux. Auxiliary script
  Accessible without login Plain text file Location-WithEffect.js Aux. Auxiliary script
  Plain text file Location-WithRouter.js Class Class source
  Accessible without login Plain text file serviceWorker.js Example Example script
  Accessible without login Plain text file setupTests.js Aux. Auxiliary script

  Files folder image Files  /  examples  /  react  /  src  /  Components  
File Role Description
  Accessible without login Plain text file Contact.js Aux. Auxiliary script
  Accessible without login Image file countly.jpg Data Auxiliary data
  Accessible without login Plain text file Header.js Aux. Auxiliary script
  Accessible without login Plain text file Home.js Aux. Auxiliary script
  Accessible without login Plain text file styles.css Data Auxiliary data
  Accessible without login Plain text file Users.js Aux. Auxiliary script

  Files folder image Files  /  examples  /  symbolication  
File Role Description
Files folder imagesrc (1 file)
Files folder imagestatic (1 file)
  Accessible without login Plain text file .babelrc Data Auxiliary data
  Accessible without login Plain text file .editorconfig Data Auxiliary data
  Accessible without login Plain text file .yo-rc.json Example Example script
  Accessible without login Plain text file package-lock.json Data Auxiliary data
  Accessible without login Plain text file package.json Data Auxiliary data
  Accessible without login Plain text file README.md Doc. Documentation
  Plain text file webpack.config.js Class Class source

  Files folder image Files  /  examples  /  symbolication  /  src  
File Role Description
  Accessible without login Plain text file index.js Aux. Auxiliary script

  Files folder image Files  /  examples  /  symbolication  /  static  
File Role Description
  Accessible without login HTML file index.html Doc. Documentation

  Files folder image Files  /  lib  
File Role Description
  Plain text file countly.js Class Class source
  Plain text file countly.min.js Class Class source

  Files folder image Files  /  plugin  
File Role Description
Files folder imageboomerang (3 files)
Files folder imagega_adapter (2 files)

  Files folder image Files  /  plugin  /  boomerang  
File Role Description
  Plain text file boomerang-1.0.0.js Class Class source
  Plain text file boomerang.min.js Class Class source
  Accessible without login Plain text file countly_boomerang.js Example Example script

  Files folder image Files  /  plugin  /  ga_adapter  
File Role Description
  Accessible without login Plain text file doc.md Example Example script
  Accessible without login Plain text file ga_adapter.js Aux. Auxiliary script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:85
This week:0
All time:444
This week:4Up