- Date
Open Source Click Tracking: Track Links Without Cookies
Andrii Romasiun
A pageview tells you someone loaded a page, but it does not tell you if they downloaded a PDF, navigated to a pricing page, followed an affiliate link, or clicked a specific call to action. Measuring those precise interactions requires a different mechanism from counting general traffic.
Open-source software is defined by its licensing terms, because source-code access alone does not establish that a program is open source. The Open Source Initiative says those distribution terms must make source code available and allow modifications and redistribution.
It is easy to confuse open source with related, but distinct, software properties.
| Term | What it describes | What it does not guarantee |
|---|---|---|
| Open source | The code and license provide defined rights to inspect and modify the software. | Privacy, security, or simple deployment |
| Self-hosted | The customer operates the infrastructure and database. | That the underlying software is open source |
| Cookieless | The implementation does not rely on browser cookies or localStorage. | That it collects no personal data |
| Privacy-first | The product is designed to minimize identification and data retention. | Automatic compliance across all jurisdictions |
Swetrix bridges these distinct properties. Its Community Edition repository describes an AGPLv3, self-hostable analytics product where the event and funnel model lets you track precise user interactions alongside traffic analytics. A useful tracking setup connects a campaign source to an on-page click, and finally to a confirmed outcome, without defaulting to invasive profiling.

Separate Campaign Attribution From Click Events
A common measurement failure happens when you confuse campaign tagging with interaction tracking, because they serve entirely different purposes.
UTM parameters identify where an incoming visitor came from, and appending values to an inbound URL creates a distinct reporting source. Google's URL builder guidance recommends setting source, medium, and campaign parameters, using content to distinguish between creatives. Because these values are case-sensitive, inconsistent capitalization splits the data into separate rows.
Explicit UTM values take precedence over inferred referrer data in Swetrix, and the raw query string drops after the server processes the visit. UTMs confirm the visit origin, but they cannot tell you which button the visitor clicked ten seconds after the page finished loading.
Custom events handle those subsequent on-page choices by firing when a user takes a specific action and sending a structured payload to the analytics platform.
Search Console click data represents a third, entirely separate metric. It records a click when a user selects your page in Google search results, though it does not track what happens after the page loads.
| Question | Appropriate measurement method |
|---|---|
| Where did the visitor come from? | Referrer, UTM parameters, or a recognized click ID |
| Which link did the visitor choose? | Custom click event |
| Did the destination request succeed? | Server-side redirect log |
| Did the visitor complete the goal? | Server-confirmed transaction or conversion event |
These datasets complement each other. UTMs attribute the arrival, custom events identify the interaction, and Search Console measures the organic search performance that made the visit possible.
Choose the Tracking Method That Fits the Link
You have multiple ways to measure outbound link performance, and the correct method depends on the link type, the destination ownership, and the required reliability.
Custom browser events provide the most versatile tracking for regular buttons, internal navigation, outbound links, and pricing selections. When a user clicks a defined element, the browser fires an asynchronous event containing structured business context, such as the placement or destination category. This method fails silently if the user disables JavaScript or if a network rule blocks the tracking domain.
Server-side redirects offer higher reliability for affiliate placements, partner referrals, short links, and software downloads. Instead of pointing the user directly to a third-party destination, the link points to a route your server controls. The server logs a minimal request, validates the destination, and issues an HTTP redirect. This guarantees a tracking record even if browser scripts fail, though the trade-offs include added redirect latency, the need to filter bot requests, and the responsibility to secure the route against open-redirect vulnerabilities.
Browser navigation poses a specific technical challenge for client-side events. If a user clicks an outbound link, the browser immediately begins unloading the current page to load the destination, meaning an ordinary asynchronous tracking request might terminate before it reaches the server.
The W3C's Beacon specification addresses this timing problem by providing a non-blocking way to deliver analytics data around page transitions. Using sendBeacon() queues the request before page unloading and lets it proceed without blocking other time-critical work. For that reason, test external links in mobile browsers and private browsing modes, as well as in single-page applications, to confirm delivery behavior.

Implement Outbound Link Tracking With Swetrix
Instrumentation requires clean code and a stable naming convention. Swetrix handles custom events using the ev identifier and a meta object for context.
The following JavaScript function demonstrates how to record a click, normalize the destination URL, and send a structured payload using the Swetrix SDK.
function trackOutboundClick(link) {
const destination = new URL(link.href, window.location.href);
swetrix.track({
ev: "OUTBOUND_LINK_CLICK",
meta: {
destination: `${destination.hostname}${destination.pathname}`,
placement: link.dataset.placement || "unknown"
}
});
}
Calling this function from links marked with specific data attributes keeps your setup organized. Normalizing the URL strips out query strings, preventing unexpected personal data or third-party session tokens from entering your analytics database.
Separate your business questions into distinct event names by using OUTBOUND_LINK_CLICK for general navigation, DOWNLOAD_CLICK for files, and AFFILIATE_CLICK for partner revenue paths. Place the variables that change, such as the specific placement on the page, inside the metadata object.
Swetrix enforces specific architectural limits on this data payload: event names accommodate up to 256 characters, and the metadata object supports primitive values for up to 20 keys. The combined string length of all metadata values needs to remain below 1,000 characters.
Keep personal data out of this structure entirely by avoiding event names or metadata values that contain an email address, an unhashed account ID, a phone number, or a sensitive search term. Privacy-focused architecture relies on disciplined data collection at the implementation level.
Connect Clicks to Conversions and SEO Decisions
Raw click volume rarely defines business success because a click primarily acts as an intent signal. Treating that signal as a completed outcome misrepresents the performance of a campaign.
You model the actual user journey by building a conversion funnel. A standard flow moves from the campaign landing page to a CTA click, then to a signup form start, and finally to a confirmed product activation. When you track user signups as a distinct server-validated event, you measure the exact drop-off between intent and completion.
High click volume combined with low completion usually points to a specific failure, such as a slow destination page, a misleading call to action, or a broken form. Combining click events with performance monitoring and error tracking helps identify these bottlenecks.
Reporting requires a defined denominator, with total click events showing overall activity and unique clickers showing audience participation. Swetrix provides a unique parameter that saves only one matching event per user session, keeping a single dedicated user from skewing a metric by clicking a button multiple times.
Applying these patterns directly to search optimization and product design uncovers actionable improvements. If a specific internal link placement generates a high CTR, use that slot for priority pages. If users constantly click non-linked elements, you have discovered missing navigation paths. This behavioral data provides the qualitative context that Search Console impression metrics lack. When you track button clicks to optimize a specific conversion route, isolate that event from general navigation metrics to maintain a clear signal.
Keep Cookieless Tracking Privacy-Conscious
Dropping cookies from your tracking script reduces data exposure, but it does not automatically exempt an installation from privacy regulations.
The UK Information Commissioner's guidance on storage and access technologies covers more than browser cookies, including tracking pixels, link decoration, device fingerprinting, web storage, and scripts or tags. It explains how PECR and, where relevant, data protection law apply when those technologies store information or access information stored on a person's device.
Swetrix operates on a minimized data model where the tracking script avoids cookies and localStorage entirely. IP addresses and user agents undergo server-side processing to determine unique pageviews without storing the raw values in the database. Instead, the system generates a salted hash that expires quickly, remaining valid for no longer than 30 minutes or until midnight UTC.
This model lets you measure how cookieless tracking works accurately while minimizing surveillance risk.
Implementing an identification function alters this privacy model. Sending an identify() call or passing a persistent profile ID links anonymous session activity to a specific user profile. Retain this capability for situations where product analytics explicitly demand it, and review the local notice, purpose, access, and consent requirements before enabling it.

Decide Between Managed and Self-Hosted Analytics
Choosing a privacy-focused analytics stack requires deciding who operates the infrastructure, and Swetrix offers both a managed Cloud service and a self-hostable Community Edition.
The Community Edition is licensed under AGPLv3 and provides the core analytics capabilities needed for a production deployment, including traffic analytics, custom event tracking, sessions, funnels, performance metrics, and error monitoring. You download the repository, configure the containers, and run the service on your own hardware or cloud instances.
Self-hosting gives you complete control over data location, network access, and retention policies, though it makes you responsible for server maintenance, database backups, capacity scaling, and applying security patches.
Swetrix Cloud shifts that operational burden to the vendor. The Cloud tier manages the hosting infrastructure, scales resources during traffic spikes, and applies software updates automatically. The repository documentation notes that session replays and specific advanced features operate exclusively in the Cloud environment.
| Requirement | Swetrix Cloud | Swetrix Community Edition |
|---|---|---|
| Cookieless analytics | Yes | Yes |
| Custom events & click tracking | Yes | Yes |
| Funnels & product analytics | Yes | Yes |
| Session replays | Available in Cloud | Detailed as Cloud-only |
| Hosting & maintenance | Managed by Swetrix | Operated by the customer |
| Source control & infrastructure | Managed infrastructure | Full customer control |
Self-hosting requires auditing the resulting data flow. Configuring firewall rules restricts API access, while establishing an automated backup routine and setting clear retention limits protects session data over time.
Close With a Practical Measurement Checklist
Tracking outbound links and custom events successfully requires consistency across three phases of deployment.
Before writing any tracking code, define the business question by determining whether the interaction represents simple navigation, an intent signal, or a finalized transaction. Documenting your naming convention for events and metadata keys helps clarify exactly which campaign details belong in UTM parameters versus custom event payloads.
During implementation, normalize recorded destination URLs by stripping away query strings by default. Grouping different interaction types into separate event names keeps downloads, affiliate clicks, and standard outbound links distinct. Testing the implementation confirms that links trigger events when activated by a keyboard, a touch interface, or a middle-click to open a new tab. For modern applications, a robust router handles single page application pageviews and interaction events without dropping payloads during fast navigation.
After launch, auditing the incoming data against destination reports or internal server logs verifies accuracy. Reviewing the event metadata ensures no personal information, email addresses, or raw tokens accidentally leaked into the tracking payload. Building a funnel report that connects inbound campaign traffic to the click event, and finally to a confirmed conversion, identifies where users abandon the journey.
Track the clicks that matter with Swetrix to avoid cookies and invasive profiling without giving up funnels and product analytics. Try Swetrix Cloud for managed analytics, or self-host the open-source Community Edition when infrastructure control takes precedence over convenience. Get started at Swetrix.