Click Here document.getElementById('trackable-link').addEventListener('click', function(event) { event.preventDefault(); // Prevent the default link behavior // Generate a unique query parameter (e.g., timestamp) const uniqueParam = new Date().getTime(); // or Math.random() // Construct the new URL with the unique parameter const originalUrl = this.href; const newUrl = originalUrl.includes('?') ? `${originalUrl}&uniqueClick=${uniqueParam}` : `${originalUrl}?uniqueClick=${uniqueParam}`; // Log the click (optional) console.log('Link clicked:', newUrl); // Redirect to the new URL window.location.href = newUrl; });
Comments
Post a Comment