analytics-ai
v1.0.3
Published
This package provides a lightweight and easy-to-integrate analytics solution for web applications. It automatically tracks views and clicks on all `div` and `button` elements, captures page views, and monitors time spent on the page. The collected data is
Downloads
3
Readme
Analytics Package by Adarsh
This package provides a lightweight and easy-to-integrate analytics solution for web applications. It automatically tracks views and clicks on all div
and button
elements, captures page views, and monitors time spent on the page. The collected data is sent to a specified server endpoint for further processing and analysis.
Features
- Automatic Event Tracking: Automatically captures clicks and views for all
div
andbutton
elements. - Page View Tracking: Logs each page view along with the URL.
- Time Spent Tracking: Measures and logs the total time a user spends on the page.
- Data Collection: Sends the captured data to a specified server endpoint using the
sendBeacon
method, ensuring data is sent even if the user leaves the page.
Installation
Install the package via npm:
Install the package via npm: npm install analytics-ai
Usage
Import and Initialize In your web application, import and initialize the analytics package:
import { initAnalytics } from 'analytics-ai';
const analytics = initAnalytics('https:/ourAiServer/collect-data');
// Additional tracking can be added if necessary analytics.trackTimeSpent();
Handling Dynamic Content
If your application dynamically adds content, the package will automatically observe DOM changes and track newly added div and button elements.