Created
March 10, 2018 23:44
-
-
Save da2x/4a2374cb6ece2fa0b27ba295cd85a68a to your computer and use it in GitHub Desktop.
Hash-based tracking links
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Tracking links that use hashes rather than query parameters. | |
Improves privacy by not including campaign data in referral-out links. | |
Improves CDN/proxy privacy by not sharing campaign data with them. Also improves caching! | |
Tracking links can (optionally) be removed from URLbar/history without a redirect. | |
Example links: | |
/document#s:feed | |
/document#s:email | |
*/ | |
if (document.location.hash && document.location.hash.startsWith('#s:')) | |
{ | |
var source = document.location.hash.split(':')[1]; | |
// TODO: add source to tracking object. | |
if (history!==undefined) | |
{ | |
history.replaceState({}, document.location.toString(), | |
document.location.toString().replace(document.location.hash,'')); | |
} } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment