• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Click tracking in Java

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a link in my HTML page. which a user can click and go to another web site. I have a counter variable which i want to increase only when a user does a search or click on any link on that website.
want to develope a click tracking system. at present I can track the details about a user when he clicks on any link on my website. but now my requirement is that once a user click on the link and move on to some other web site.(link opens the website for which the link is for) I should be able to track whether he clicked on any link or made a search on that new web site.
i found some click traking tools in PHP but can any one tell me how should i do it in JAVA
thanks in advance please help.
i have one week to do this
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

If you are opening a new window then you have object called window.opener.
You can set a hidden variable in your website and from other website you can set it by saying window.opener.document.form.hdnval.value.
This will work if the site domains are same.
But if you are chaging domains then you can exchange cookies between the two websites.On the other website set the cookie stating what values user has clicked and on your website get that cookie.
Hope this helps.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thankfully, this is not possible.

Browsers are very careful to make sure this kind of cross site scripting is not possible. They also do not allow the sharing of cookies across domains; which negates what was said in the first reply to your question.

Do you think it would be ethical for a website to track your activity on other sites? How would you feel if you knew that all of your activity on the web was being monitored by some site which you have visited but is no longer active in your browser?
 
vikas prasad
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actually i have no access to other website. say for example i have a link in my page for www.kelkoo.co.uk . now when a user in my web site clicks this link . I takes him to kelkoo website. now when the user make a search on this website then i should be able to update the variable in my web site.
so you see i dont have access to kelkoo web site.
 
vikas prasad
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so can you tell me how does these sites work
web page
think about any pice comparison site.
how do they work.
you search for any thing and they give a list of different companies offering that service.
i am sure definately they can search another web sites.
any idea how this work
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I understand that.

Once the user clicks the link to a site on another domain, it is no longer your business to know what searches they make or what links they click.
Browser makers are very careful to insure that you can't do things like this.

If you want to track usage on some other site, you should contact the owners of that site and ask them to put code in their site that sends the tracking information to you.
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try this.This might help you.

I have noticed in Google search that when it gives you a list of matching URL's and when you click on any one of the URL's . It doesn't take you directly to that site.Rather you see some other URL in the status bar (lower , left in IE or fFox) , which in turn takes you to the correct site , that the link points to.

I think Google does it for tracking or for collecting statistics.

You might want to implement something like that.When the user would click on the link (the link would have a id attached with it , to uniquely identify the link), it would be redirected to your application , you can increase the count for that link according to the id that came from the client and then finally redirect the user to the correct location.
[ June 22, 2007: Message edited by: Rahul Bhattacharjee ]
 
Pallavi Srivastava
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you cannot share cookie directly.
But you can do something like this:


Then you can retrieve cookies with request.
I had reqmt to communicate between cross domains and have used similar thing and its working.
There is also Single sign on where users sign on multiple websites directly.I read the articles and they too use cookies for that.
I could not figure out any other way so its a workaround!
Thanks.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rahul Bhattacharjee:
You can try this.This might help you.

I have noticed in Google search that when it gives you a list of matching URL's and when you click on any one of the URL's . It doesn't take you directly to that site.Rather you see some other URL in the status bar (lower , left in IE or fFox) , which in turn takes you to the correct site , that the link points to.

I think Google does it for tracking or for collecting statistics.

You might want to implement something like that.When the user would click on the link (the link would have a id attached with it , to uniquely identify the link), it would be redirected to your application , you can increase the count for that link according to the id that came from the client and then finally redirect the user to the correct location.

[ June 22, 2007: Message edited by: Rahul Bhattacharjee ]



Yes, Google's links point back to Google and then redirect you to the actual site but once you leave Google and are on that site, Google is out of the picture and has no ability to track what links you click or what searches you make on that site.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vikas prasad:
so can you tell me how does these sites work
web page
think about any pice comparison site.
how do they work.
you search for any thing and they give a list of different companies offering that service.
i am sure definately they can search another web sites.
any idea how this work



That's a different issue.
You perform a search on their site, they in turn, search several other sites and build a page with the results. You were asking about tracking usage on sites other than your own.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:
but once you leave Google and are on that site, Google is out of the picture and has no ability to track what links you click or what searches you make on that site.



True ,I was suggesting this with the view that the poster wants to track statistics only for his site.

[vikas prasad:] I should be able to track whether he clicked on any link or made a search on that new web site.



Do you want to track user clicks for only your site or you want to tack user clicks further too.
In case you want the later , it would not work.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pallavi Srivastava:
Yes you cannot share cookie directly.
But you can do something like this:


Then you can retrieve cookies with request.
I had reqmt to communicate between cross domains and have used similar thing and its working.
There is also Single sign on where users sign on multiple websites directly.I read the articles and they too use cookies for that.
I could not figure out any other way so its a workaround!
Thanks.




This assumes that you have control over both sites; or at least are able to persuade the owner of the other site to paste your code into their site.

You can not, however, just read the cookies from any domain that you have linked to from your own pages.
 
vikas prasad
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Rahul for understanding. at present i can monitor the link directly. but my point is once the new website is open how can i make the browser call a method in my website.
i will tell a senario: lets say A user in my website click a link. which takes him to other website. now say i also passed a parameter with that link. now the user is on another website. (up till now the variable in my website has not been incremented). now the user makes a search or click any link on that website. now what i want is that the browser should do the search(which is what it is suppose to do in that web site) as well call a method on my website with the id what i passed with the link.
then i will be able to increment my variable.

any idea
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vikas prasad:
at present i can monitor the link directly. but my point is once the new website is open how can i make the browser call a method in my website.


I do not think this would be possible beyond you own web site.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

now when the user make a search on this website then i should be able to update the variable in my web site.


Why do you think that? As Ben pointed out, for ethical reasons you should not be able to do that, and for technical reasons you are not able to do that.
 
vikas prasad
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please check this web site
http://www.britishrewards.co.uk/index.pl
and then register yourself you will see there is an option for paid click
and when you are on that site you will find soe click are paid instantly ok.
but only when you do some search or cick on their web site. if you just click on the first website you get nothing. try this and then you will understand what i want.
 
vikas prasad
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
pallavi you were saying something about cookies. lets say if a user click on any link in my web site i store a cookie on his computer and then he goes to other website by that link now when he makes a search on that web site that website will store a cookie on his computer.
so is there a way that the cookie which is from my website sees that there is a cookie from other web site. and when user refreshes the page in my web site i should be able to get the information about the cookie set by other web site.
I mean is there any way cookies can comunicate with other cookie. or say my cookie will have a variable which will only increas when it sees that a cookie from another page is also there on the user computer.
any idea?
 
Pallavi Srivastava
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But Vikas you need to have control over other websites for that,as other people are suggesting.I will look into the link you have sent later and will let you know.
Is this

http://www.britishrewards.co.uk/index.pl

a paid link or anyone can register.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vikas prasad:
please check this web site
http://www.britishrewards.co.uk/index.pl
and then register yourself you will see there is an option for paid click
and when you are on that site you will find soe click are paid instantly ok.
but only when you do some search or cick on their web site. if you just click on the first website you get nothing. try this and then you will understand what i want.









I don't think too many people will take the time to register with that site to see what you want but from your description, I'm guessing that they're proxying entire sites.

In other words when you click the link, you're not going to the other site, they're going to the other site, then streaming it to you from their server.
This would involve parsing the other site and re-writing all of the links, image src attributes, form actions, etc to point back to their site so they can perform the request and stream the results back.

This is slightly more ethical than what you were asking for earlier because the user actually has to sign up for this and (if they are smart enough to read the URL in the browser's address window) they will know that they are not actually on the other site. It would still be unethical if the sites to which they link have given express permission for this. It wouldn't be difficult for these sites to pull the plug on this by banning the IP of the site doing the proxying.
[ June 22, 2007: Message edited by: Ben Souther ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vikas prasad:
pallavi you were saying something about cookies. lets say if a user click on any link in my web site i store a cookie on his computer and then he goes to other website by that link now when he makes a search on that web site that website will store a cookie on his computer.
so is there a way that the cookie which is from my website sees that there is a cookie from other web site. and when user refreshes the page in my web site i should be able to get the information about the cookie set by other web site.
I mean is there any way cookies can comunicate with other cookie. or say my cookie will have a variable which will only increas when it sees that a cookie from another page is also there on the user computer.
any idea?




Cookies are nothing more than a string of data, saved by the browser on the user's machine. The browser, for security reasons will not allow any site (domain) to read or write to cookies set by another domain.
They are not programs and they can not communicate with one another.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Going back to the proxy idea...

Not only are the ethics of something like this questionable but, if any sensitive information (Credit card numbers, personal information, etc..) were to pass through the proxy without the expressed permission of both the end user and the site being proxied, you could could be sued and/or face criminal charges.
 
vikas prasad
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so according to you people this only be done if i have some control on the other site. ok i can understand but can you tell me how does price comparison sites works.
say kelkoo if you search for a product they will give you details about almost all the sites where you can find that product. that mean they also have some control over those websites. and if not how do they do that.?
[ June 22, 2007: Message edited by: Ben Souther ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please don't post the same question to more than one forum; see our explanation here. I've deleted the other copy of this thread.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vikas prasad:
so according to you people this only be done if i have some control on the other site. ok i can understand but can you tell me how does price comparison sites works.
say kelkoo if you search for a product they will give you details about almost all the sites where you can find that product. that mean they also have some control over those websites. and if not how do they do that.?



They don't need control over those sites to do that.
The user searches on your site.
You then make HTTP requests to all of the other sites, gather up the prices for the product in question, and then return a page with all of that data to the user.

These are different issues.
 
vikas prasad
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

the user searches on your site.
You then make HTTP requests to all of the other sites, gather up the prices for the product in question, and then return a page with all of that data to the user.


where can i find details about this and can you explain how to do this
please
thanks for your help in advance.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not a trivial task and I'm not sure, exactly what any particular site is doing.

Java provides a java.net.URLConnection class that allows you to make web requests from within a Java class.

The Jakarta group at the Apache Foundation has written some higher level libraries.
http://jakarta.apache.org/commons/httpclient.

That should get you going in the right direction.
 
Pallavi Srivastava
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Go through this article.
This might help.

http://www.javaworld.com/javaworld/jw-04-2002/jw-0426-cookie.html?page=5
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pallavi Srivastava:
Go through this article.
This might help.

http://www.javaworld.com/javaworld/jw-04-2002/jw-0426-cookie.html?page=5



How is an article on cookie management going to help him with this?
He's already said that he has no control over the sites that he wants to do this with.
 
reply
    Bookmark Topic Watch Topic
  • New Topic