User ID Tracker
Maintain session continuity. The ID Tracker script generates a unique identifier for each user, allowing you to recognize returning visitors and track user behavior across your domain using persistent browser cookies.
Live Demo
Visitor Identification String
Generating...
This ID is unique to your current browser session.
Copy the Script
<script>
function setVisitorID() {
// 1. Generate a random unique ID
// Combines a random number with the current timestamp
var id = "User-" + Math.floor(Math.random() * 100000) + "-" + new Date().getTime();
// 2. Set Expiration (2 Years)
var exp = new Date();
exp.setTime(exp.getTime() + (365 * 2 * 24 * 60 * 60 * 1000));
// 3. Set the Cookie
document.cookie = "visitorID=" + id + "; expires=" + exp.toUTCString() + "; path=/";
return id;
}
// 4. Run on page load
// Only set a new ID if one doesn't already exist
if (document.cookie.indexOf("visitorID") === -1) {
setVisitorID();
}
</script>
Frequently Asked Questions
The script creates a unique string by combining a random number (Math.random) with the current timestamp (new Date().getTime()).
It is sufficient for basic tracking but is not cryptographically secure. It should not be used for sensitive authentication or financial transactions.
No, the ID is stored entirely on the client side (in the user's browser). You only need a database if you want to save specific data associated with that ID on your server.