How To Set Up Affiliate Link Tracking With Google Analytics
I set up this code a good while ago but recently realized that I needed to be sharing this information with the general public.
Basically, If you want to track an external link in Google Analytics as a goal or just to know what’s happening, here is some code to get it done.
Code for JS incude
function goNow(location, linkType){
urchinTracker("/aff-link/" + linkType);
//document.location = location;
window.open(location);
}
Code for your header in every page (remove spaces in open and closing script tags)
< script src="/javascripts/aff-track.js" type="text/javascript">< /script>
Code for your links(remove spaces in open and closing a tags)
< a href="javascript:void(0);" onClick="goNow(' http://www.site.com/affvar=AFFID','linkID');">Link Text< /a >
Use the linkID for whatever you want to show up to differentiate different link types.
It will show up in GA as a page load for www.site.com/aff-link/linkID
Once you get it working, you can set up www.site.com/aff-link/ as a goal page with a $$ value.
Good luck and happy tracking.



