Howto : tag affiliate info in the stats
Let's say you runs www.BobsRentals.com and the site www.RentalSource.com links to you like this
http://www.BobsRentals.com/page1.html?id=RentalSource
You can use some code to pass that id into the Custom Tags report in StatCounter. This will help you keep track of affiliates linking to you. In your reports you will see something like this
This code must go before your StatCounter tracking code.
<script type="text/javascript">
var myRE = /\?id=\w*/g;
var _statcounter = _statcounter || [];
var x;
try {x = document.URL.match(myRE)[0].slice(4);
_statcounter.push({"tags": {"affiliate": x}});
} catch(e) {}
</script>
Note the bold ?id=
This needs to be changed to whatever parameter name you would like to track
Also note the bold slice(4)
This represents the first part that identifies the data you want (?id=), but is not part of that data. For example if your landing URL is like this
http://www.BobsRentals.com/page1.html?linkID=RentalSource
Then your code would look like this
<script type="text/javascript">
var myRE = /\?linkID=\w*/g;
var _statcounter = _statcounter || [];
var x;
try {x = document.URL.match(myRE)[0].slice(7);
_statcounter.push({"tags": {"affiliate": x}});
} catch(e) {}
</script>
In this case the text ?linkID= is 7 characters long and we need to trim that off.
Let's say you runs www.BobsRentals.com and the site www.RentalSource.com links to you like this
http://www.BobsRentals.com/page1.html?id=RentalSource
You can use some code to pass that id into the Custom Tags report in StatCounter. This will help you keep track of affiliates linking to you. In your reports you will see something like this


This code must go before your StatCounter tracking code.
<script type="text/javascript">
var myRE = /\?id=\w*/g;
var _statcounter = _statcounter || [];
var x;
try {x = document.URL.match(myRE)[0].slice(4);
_statcounter.push({"tags": {"affiliate": x}});
} catch(e) {}
</script>
Note the bold ?id=
This needs to be changed to whatever parameter name you would like to track
Also note the bold slice(4)
This represents the first part that identifies the data you want (?id=), but is not part of that data. For example if your landing URL is like this
http://www.BobsRentals.com/page1.html?linkID=RentalSource
Then your code would look like this
<script type="text/javascript">
var myRE = /\?linkID=\w*/g;
var _statcounter = _statcounter || [];
var x;
try {x = document.URL.match(myRE)[0].slice(7);
_statcounter.push({"tags": {"affiliate": x}});
} catch(e) {}
</script>
In this case the text ?linkID= is 7 characters long and we need to trim that off.
Last edited: