https://github.com/altcha-org/tracker
JavaScript client for ALTCHA Analytics.
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.7%) to scientific vocabulary
Keywords
Repository
JavaScript client for ALTCHA Analytics.
Basic Info
- Host: GitHub
- Owner: altcha-org
- License: mit
- Language: TypeScript
- Default Branch: main
- Homepage: https://altcha.org/
- Size: 66.4 KB
Statistics
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
- Releases: 3
Topics
Metadata Files
README.md
ALTCHA Analytics Tracker
This repository contains the front-end library for collecting analytics data with ALTCHA Analytics.
Why ALTCHA Analytics?
ALTCHA Analytics provides a privacy-first, GDPR-compliant alternative to traditional analytics platforms like Google Analytics. Unlike most other services, it operates without cookies or fingerprinting, ensuring that all data is anonymized by default.
Key Features: - Compliant with GDPR, CCPA, and PECR regulations - No cookies or fingerprinting required - Flexible: Use for web, app, or API analytics - Customizable event tracking and properties - Lightweight (~4kB gzipped)
Installation & Usage
You can integrate ALTCHA Analytics in two ways:
- Module (Recommended for modern frameworks such as React, Vue, Angular)
- Script Tag (Simple HTML inclusion)
1. Module Installation (Preferred for Frameworks)
Install via npm:
bash
npm install @altcha/tracker
Initialize the tracker in your app:
```javascript import { Tracker } from '@altcha/tracker';
const tracker = new Tracker({ projectId: 'pro_...', }); ```
2. Script Tag Integration
Simply add the following snippet to your HTML:
```html <script defer data-project-id="pro_..." src="https://eu.altcha.org/js/script.js"
```
Make sure to replace "pro_..." with your unique projectId.
Configuration
The Tracker class constructor accepts the following configuration options:
allowSearchParams?: string[]– By default, the script removes all query parameters (those after?in the URL). Use this option to whitelist specific parameters that should be tracked.apiUrl?: string– Override the default API URL for reporting events.appVersion?: string– Track the version of your application (max 12 characters).click?: IBaseExtensionOptions | boolean– Disable or configure theclickextension (see below for details).cookie?: ICookieExtensionOptions | boolean– Disable or configure thecookieextension.debug?: boolean– Enable debug mode for logging.globalName?: string | null | false– Override the default global variable name for the Tracker instance. Set tonullto skip global registration.hash?: IBaseExtensionOptions | boolean– Disable or configure thehashextension.keyboard?: IBaseExtensionOptions | boolean– Disable or configure thekeyboardextension.mouse?: IBaseExtensionOptions | boolean– Disable or configure themouseextension.projectId: string– Required ALTCHA project ID (format:pro_{unique_id}).pushstate?: IBaseExtensionOptions | boolean– Disable or configure thepushstateextension.respectDnt?: boolean– Whentrue, the tracker will not report any events if the user's browser is configured withDo Not TrackorglobalPrivacyControl.uniqueId?: string– Provide the user's unique ID, if applicable, to track returning visitors.visibility?: IVisibilityExtensionOptions | boolean– Disable or configure thevisibilityextension.
These options can also be provided as attributes in the <script> tag, for example: data-project-id="pro_...".
Example Configuration:
javascript
new Tracker({
projectId: 'pro_...',
appVersion: 'v1.0.1',
debug: true,
respectDnt: true,
allowSearchParams: ['page_id'],
});
HTML Example Configuration:
```html <script defer data-project-id="pro_..." data-app-version="v1.0.1" data-debug="true" data-respect-dnt="true" src="https://eu.altcha.org/js/script.js"
```
Extensions
Tracking features are provided through "extensions," which can be individually enabled or disabled depending on your needs and privacy concerns.
Click
Enabled by default.
Tracks user mouse/pointer interactions, detecting exit events and outbound links.
Cookie
Disabled by default.
The cookie extension tracks returning visitors by setting a small cookie (_altcha_visited=1) that expires in 30 days.
You can configure this extension with the following options:
js
new Tracker({
projectId: '...',
cookie: {
// Cookie expiration in days
cookieExpireDays: 30,
// Cookie name
cookieName: '_altcha_visited',
// Cookie path (defaults to '/')
cookiePath: '/',
}
})
Note: Enabling this extension may require user consent under GDPR.
Filter
Enabled by default.
Event filtering allows you to exclude events based on the user-agent, hostname, or a custom filter function. This helps you ensure only relevant events are tracked.
By default, the filtering extension ignores:
- Bots and crawlers.
- Private hostnames such as
localhost,127.0.0.1, and*.local.
You can also manually prevent your own events from being tracked by setting localStorage.altcha_ignore=true in the browser.
```js new Tracker({ projectId: '...', filter: { // Set to true to allow reporting of events made by bots and crawlers (default: false). allowBots: true,
// A custom function for additional event filtering.
// Return `false` to ignore the event, or `undefined` to continue with the built-in checks.
checkFn: (event) => {
return false; // Example: Ignore all events.
},
// An array of hostnames to ignore from tracking.
// Override the default list of private hostnames.
hostnames: ['localhost'],
} }); ```
Hash
Disabled by default.
Tracks the #hash part of the URL when using hash-based routing in your application.
Keyboard
Enabled by default.
Detects exit events triggered by keyboard shortcuts (e.g., closing the tab).
Mouse
Enabled by default.
Detects exit events triggered by pointer (e.g., closing the tab using the mouse).
PushState
Enabled by default.
Automatically detects pageviews when history.pushState() is called. If disabled, use .trackPageview() or .trackEvent() to manually report events.
Visibility
Enabled by default.
Tracks exit events when the tab/window is hidden during page unload.
Implementation Details
This script reports collected events in bulk when the page unloads, using the sendBeacon() function. You can configure the API endpoint via the apiUrl option.
Exit Events
Exit events are reported when the user leaves the website (e.g., by closing the tab or navigating elsewhere).
To track these events accurately, ensure the following extensions are enabled: click, keyboard, mouse, visibility. Disabling these will reduce the accuracy of visit duration data.
Respect for Privacy (Do Not Track)
If you respect users' privacy preferences and want to disable tracking when Do Not Track is enabled in the browser, you can set the respectDnt option to true.
javascript
new Tracker({
projectId: '...',
respectDnt: true, // disable tracking for users with Do Not Track enabled
});
Debug Mode
Enabling debug mode logs additional information to the browser console, which is helpful for development purposes.
javascript
new Tracker({
projectId: '...',
debug: true, // enable debug logging
});
API Reference
The following is a quick overview of the main methods available in the ALTCHA Analytics tracker:
trackPageview(event: IEvent, unload: boolean = false): Track page views.trackEvent(event: IEvent, unload: boolean = false): Track custom events.destroy(): Destroys the tracker instance.
Types
For TypeScript types and interfaces, see /src/types.ts.
License
ALTCHA Analytics is licensed under the MIT License. See the LICENSE file for more details.
Owner
- Name: ALTCHA
- Login: altcha-org
- Kind: organization
- Website: https://altcha.org
- Repositories: 26
- Profile: https://github.com/altcha-org
GDPR compliant, self-hosted CAPTCHA alternative.
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- npm 16 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 3
- Total maintainers: 1
npmjs.org: @altcha/tracker
JavaScript client for ALTCHA Analytics.
- Homepage: https://altcha.org
- License: MIT
-
Latest release: 0.2.0
published over 1 year ago