Track clicks on the client-side using query parameters
@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:
trackClick()
function inside your application code.@codeqr/analytics
script:
Add a custom domain to your CodeQR workspace
yourcompany.link
for free.This is the domain that you’ll use for your short links on CodeQR.Allowlist your site's domain
localhost
to the Allowed
Hostnames list temporarily. This will allow local events to be ingested by
CodeQR. Don’t forget to remove it once you’re ready to go live!Install the CodeQR client-side SDK
Parameters
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.?via=abc123
).(Optional, but recommended): Set up a reverse proxy
Verify your setup
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:/track/click
request in your browser’s Network tab (and no errors in the Console tab).cq_id
cookie is being set upon a successful /track/click
request.codeqr_partner_data
cookie in the following format:
js-cookie
– here’s an example:
trackClick()
functionAttribute | Type | Description |
---|---|---|
timestamp | string | The timestamp of the click event |
id | string | The unique ID of the click event |
url | string | The destination URL that the link resolved to – this can vary if geo/device-targeting is enabled |
continent | string | The continent of the user who clicked the link |
country | string | The country of the user who clicked the link |
city | string | The city of the user who clicked the link |
device | string | The device of the user who clicked the link |
browser | string | The browser of the user who clicked the link |
os | string | The operating system of the user who clicked the link |
referer | string | The referrer of the user who clicked the link |
refererUrl | string | The full referrer URL of the user who clicked the link |
qr | boolean | Whether the click event was triggered by a QR code scan |
ip | string | The IP address of the user who clicked the link (non-EU users only) |