@codeqr/analytics script, you can track clicks on the client-side using query parameters (e.g. ?via=john, ?ref=jane).
A few use cases include:
- You’re running a referral program with dual-sided incentives and want to display a banner that says: “John referred you to Acme and gave you 25% off”
- You have dynamically generated referral pages (e.g. Tesla) and want to track clicks using a
trackClick()function inside your application code. - You are migrating from an existing affiliate management platform (e.g. Rewardful) that uses query parameters to track conversions.
Quickstart
Here’s how you can enable client-side click-tracking with the@codeqr/analytics script:
1
Add a custom domain to your CodeQR project
First, you’ll need to add a custom short link domain to your CodeQR project. You can use a domain you already own, or leverage our free .link domain offer to register a custom domain like
yourcompany.link for free.This is the domain that you’ll use for your short links on CodeQR.2
Allowlist your site's domain
Then, you’ll need to allowlist your site’s domain to allow the client-side click events to be ingested by CodeQR. To do that, navigate to your project’s Analytics settings page and add your site’s domain to the Allowed Hostnames list.

3
Install the CodeQR client-side SDK
Next, install the CodeQR client-side SDK and initialize it with the domain you added in the previous step.Here’s the full list of parameters you can pass to the script:
Parameters
Parameters
url
default:"https://api.codeqr.io"
The base URL for the CodeQR API. This is useful for setting up reverse
proxies to avoid
adblockers.
first-click | last-click
default:"last-click"
The attribution model to use for the analytics event. The following
attribution models are available:
first-click: The first click model gives all the credit to the first touchpoint in the customer journey.last-click: The last click model gives all the credit to the last touchpoint in the customer journey.
CookieOption Object
JSON-stringified object
Configure the domains that CodeQR will track. The following properties are available:
string
default:"via"
The query parameter to listen to for client-side click-tracking (e.g.
?via=abc123).4
(Optional, but recommended): Set up a reverse proxy
To avoid ad-blockers from blocking your click-tracking requests, we recommend setting up a reverse proxy.Refer to the Reverse-proxy support guide to learn how to set one up.
5
Verify your setup
To verify that your click-tracking is working, run your website locally and append the URL with the unique key of your short linkFor example, if your short link is
https://go.example.com/abc123, you’ll need to append ?via=abc123 to the URL.Once you’ve done that, check if the following is true:- There is a successful
/track/clickrequest in your browser’s Network tab (and no errors in the Console tab). - The
cq_idcookie is being set upon a successful/track/clickrequest. - The click tracked correctly in the Events tab of your CodeQR project.
Manually tracking clicks with the trackClick() function
This is helpful for tracking clicks on:
- Dynamically generated referral pages (e.g. Tesla)
- Dynamic user-generated content/webpages:
- CodeQR’s public analytics dashboards (e.g. app.codeqr.io/share/:slug)
- Tella’s video pages (e.g. tella.tv/video/:slug)
This feature is coming soon. If you’d like early access, please contact
us.
Differences from server-side click-tracking
Server-side click-tracking is enabled by default for all CodeQR links and come with the following attributes:
These events happen on the server-side and cannot be blocked by browser extensions or ad-blockers, which improves the accuracy of your analytics data.

