mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-08-21 07:51:49 +02:00
Referral tracking
This commit is contained in:
16
index.html
16
index.html
@@ -61,19 +61,7 @@
|
||||
|
||||
<script src="article.js"></script>
|
||||
|
||||
<!-- for social stuff -->
|
||||
<script type="text/disabled">
|
||||
if(window.location.toString().indexOf("localhost") === -1) {
|
||||
// no tracking info: http://support.addthis.com/customer/portal/articles/1013558-removing-all-hashtags-anchors-from-your-urls
|
||||
var addthis_config = addthis_config||{};
|
||||
addthis_config.data_track_clickback = false;
|
||||
addthis_config.data_track_addressbar = false;
|
||||
var script = document.createElement("script");
|
||||
script.setAttribute("async", true);
|
||||
script.src = "http://s7.addthis.com/js/300/addthis_widget.js#pubid=xa-516a3187281448fc";
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- referral tracking, because I like knowing who's linking to my book -->
|
||||
<script src="lib/site/referrer.js" async></script>
|
||||
</body>
|
||||
</html>
|
||||
|
39
lib/site/referrer.js
Normal file
39
lib/site/referrer.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* This script collects information on visitors, based
|
||||
* on their client session. It finds out which page they
|
||||
* were on when they go there, and by virtue of sending
|
||||
* that information to the logger, their IP. This is
|
||||
* information that you're sending already, anyway, but
|
||||
* I want you to know that this is what's going on.
|
||||
*
|
||||
* Which is why this script is not obfuscated. It simply
|
||||
* grabs your document.referrer value, which (unless Do
|
||||
* Not Track is enabled) will contain the location of
|
||||
* the page you were on before you clicked a link to this
|
||||
* page, and GETs that to my logger. That GET operation
|
||||
* comes from your computer, so will have your IP as part
|
||||
* of the HTTP headers.
|
||||
*
|
||||
* And that's all I really care about, because I want to
|
||||
* know how many people visit this page, and roughly where
|
||||
* they're from (gasp! IPs can be turned into rough
|
||||
* geographical location O_O).
|
||||
*
|
||||
* If you want to know what logger.php looks like, hit up
|
||||
* github. It's in referrer/logger.php
|
||||
*
|
||||
*/
|
||||
(function referrer(l) {
|
||||
var page = l.substring(l.lastIndexOf('/')+1).replace(".html",'');
|
||||
page = page || "index.html";
|
||||
// we don't care about file or localhost, for obvious reasons
|
||||
var loc = window.location.toString();
|
||||
if(loc.indexOf("file:///")!==-1) return;
|
||||
if(loc.indexOf("localhost")!==-1) return;
|
||||
// right, continue
|
||||
var url = "http://pomax.nihongoresources.com/pages/bezierinfo/logger.php";
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", url + "?" + "referrer=" + encodeURIComponent(document.referrer) + "&for=" + page, true);
|
||||
try { xhr.send(null); }
|
||||
catch(e) { /* you don't care about this error, and I can't see it, so why would we do anything with it? */ }
|
||||
}(window.location.toString()));
|
Reference in New Issue
Block a user