A technical deep-dive into Icodrip's click tracking infrastructure, from the redirect flow to edge function architecture.
Click tracking is the foundation of any affiliate program. Every affiliate interaction starts with a click — a visitor clicking an affiliate's unique tracking link. Icodrip's tracking infrastructure is designed for speed, reliability, and accuracy.
The tracking system processes thousands of clicks per second with sub-50ms response times. It runs on edge infrastructure distributed across global data centers, ensuring fast redirects regardless of where the visitor is located.
Every click is recorded with rich metadata including the visitor's IP address (hashed for privacy), user agent, referrer URL, country, device type, and timestamp. This data powers your analytics dashboard and helps detect fraudulent activity.
When a visitor clicks an affiliate link (e.g., yoursite.com/ref/abc123), the request hits Icodrip's Edge Function. The function performs several operations in rapid succession: it validates the referral code, looks up the associated affiliate and program, generates a unique click ID, and sets a first-party cookie on the visitor's browser.
The cookie contains the click ID and affiliate identifier, encrypted and signed to prevent tampering. It is set as a first-party cookie on your domain, which means it is not affected by third-party cookie blocking in modern browsers. The cookie's expiration matches your program's configured cookie window.
After setting the cookie, the Edge Function returns a 302 redirect to your target URL (typically your homepage or a specific landing page). The entire process — from receiving the request to sending the redirect — takes less than 50ms.
Each click record stores a comprehensive set of data points. The referral code identifies which affiliate generated the click. The click ID is a unique ULID that serves as the primary identifier for the click event and is used later during conversion attribution.
Geographic data is derived from the visitor's IP address using a lightweight GeoIP lookup performed at the edge. This includes country, region, and city. The IP address itself is hashed before storage to protect visitor privacy — the raw IP is never stored in the database.
Device and browser information is extracted from the User-Agent header. Icodrip categorizes clicks by device type (desktop, mobile, tablet), operating system, and browser. The referrer URL, if present, indicates where the visitor came from before clicking the affiliate link, which is valuable for understanding which promotion channels work best.
Icodrip's click tracking runs on Vercel Edge Functions, which deploy your code to edge locations around the world. This architecture eliminates the latency of routing requests to a single origin server. A visitor in Tokyo hits a Tokyo edge node; a visitor in London hits a London edge node.
The Edge Function uses the Neon serverless driver for database access, which is optimized for short-lived connections in serverless environments. Frequently accessed data like referral code lookups are cached in Upstash Redis to avoid database round trips for popular affiliate links.
Click logging is performed asynchronously using Vercel's waitUntil() API. The redirect response is sent to the visitor immediately, and the click data is written to the database in the background. This means the visitor never waits for a database write — the redirect is effectively instant.
If clicks are not being recorded, start by verifying the tracking link format. The URL should follow the pattern: yourdomain.com/ref/referral-code. Check that the referral code exists and belongs to an active affiliate in an active program.
Use your browser's developer tools to inspect the redirect. Open the Network tab, navigate to the tracking link, and look at the response. You should see a 302 redirect with a Set-Cookie header. If the redirect happens but no cookie is set, the issue may be with your domain configuration or cookie settings.
Icodrip provides a real-time click log in the dashboard. Navigate to Tracking > Recent Clicks to see incoming clicks as they happen. Each click entry shows the full request details, processing time, and any errors encountered. If a click is missing, check the error logs for validation failures or rate limiting events.