javascript - How to capture user interaction with a website? - Stack Overflow

How can I capture user interaction on a website?How many links a user has clicked.From where user h

How can I capture user interaction on a website? How many links a user has clicked. From where user has e. I want to create my own logic. I don't want to use any statistics tool. How can I acplish this?

Thanks in advance

How can I capture user interaction on a website? How many links a user has clicked. From where user has e. I want to create my own logic. I don't want to use any statistics tool. How can I acplish this?

Thanks in advance

Share Improve this question edited Aug 28, 2009 at 3:58 marcc 12.4k7 gold badges50 silver badges59 bronze badges asked Aug 26, 2009 at 3:56 g.revolutiong.revolution 12.3k23 gold badges83 silver badges109 bronze badges
Add a ment  | 

8 Answers 8

Reset to default 2

Place where user e from you can get by referer (document.referrer).
And if you have some kind of session or mark user(by cookies), than you can check what links are clicked by capturing onclick event. But do not put onclick on every link, just use event capturing technique. In jQuery this will be:

$('a') 
    .livequery('click', function(event) { 
        alert('clicked'); 
        return false; 
    }); 

If you want to capture what link was clicked when goes away - you should place onunload event which will send data about clicked link to your server.

There are 2 ways that I know of:

  1. make a service, and call it using a GET method on each event you want to track.
    this is something like this:

    service.php?event=pageview&time=127862936&userId=70&registered=true
    

    this way your service can work with the data.

  2. second way that I know of, which I myself use, is calling to some dummy Image on my server, chaining GET query to it, and then analyze the request to the image at the server side. each request is anylized and logged, then I build reports.

again, you need to know what events you want to grab, they are pre-defined, and need to catch and send them as they happen. you client can put a 1-script js file, but this script need to add events listeners. lets say you want to know when the use has quit the page. add an event listener to the onbeforeunload event, like this:

window.onbeforeunload = function(){
   sendStats({event:'onbeforeunload'});
}

then sendStats function breaks down the JSON and builds a query to be sent to server like this:

function sendStats(statsJSON){
    var url = [];
    for (var key in statsJSON) {
        // make sure that the key is an actual property of an object, and doesn't e from the prototype
        if( statsJSON.hasOwnProperty(key) ){  
            var sign = (!url[0]) ? '?' : '&';
            url.push(sign);
            url.push(key + '=');
            url.push( encodeURI(statsJSON[key]) );
        }
    }
    var time = new Date().getTime();
    url.push('&time=');
    url.push(time);

    var stat = new Image();
    stat.src = clientHost + 'stats.gif' + url.join('');
}

Start with web server log files, dig into it's format, try some simple stats. Then you may want to read through the code of statistic tools like awstats to enhance your vision on that.

I am a asp developer. But i think this technique will work all the time. If you want to find out from where user has e to your site, you can user some sort of tracking querystring variable www.mysite.?IMFrom=something. So you when you post your link on some third party website for e.g. say Google. Post link as www.mysite.?google=traficfromgoogle. You might have trafic ming from different otherwebsite. Have different querystring variable for each. You can also use some kind of unique id for all website which is sending trafic to you. Now create the tracking function which will track this querystring variable. Use this function where it will get called during each request. And you can now put some customized logic for each request having such querystring.

I don't think you'll need to capture this, as it is most likely already captured in web server logs by the web server itself. You just need to find the software that can analyze the logs and give you some nice metrics. There's lots of packages out there for that.

I know its not creating your own logic but if you decide you don't want to parse your server logs you could try a new service that is trying to one up google analytics: http://mixpanel./. It's real time analysis and they have a free limited account so you can try it before you upgrade.

I haven't tried their api to get stuff out yet but I imagine that you could let them collect the data from your site and do some fun stuff with it after you get it back out.

Use Google analytics and hook up site elements using their API.

record and replay the web https://www.rrweb.io/

This can be useful for: - recording user interaction/events in the browser - sending recordings to your backend only when an error

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745261967a4619250.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信