1

I'm making a conversion tracking page with postback in php, for the same I need to generate a unique transaction ID on unique click. So for tracking unique clicks I'm tracking the user's IP address with $_SERVER['REMOTE_ADDR'] and generating transaction ID by md5($_SERVER['REMOTE_ADDR']) but there is a problem. Suppose there are some users using a WiFi network or due to some other reasons they have the same IP address so the transaction ID which will be generated would be same for them because of which I will not be able to track the conversion while actually in happened because of different devices.

Can anybody suggest to me the way to resolve this problem with php or javascript?

Woodchuck
  • 3,869
  • 2
  • 39
  • 70

2 Answers2

2

You could generate an ID of some sort and put a cookie on their machine containing that ID that will identify that browser.

This isn't perfect, but it might get you what you need.

Another way it to fingerprint the device and store the value. For example you can use https://github.com/jackspirou/clientjs to do what you need. There are a few other libraries out there that a google search will turn up.

John Boker
  • 82,559
  • 17
  • 97
  • 130
  • I was just about to write that – Andreas Apr 19 '16 at 17:27
  • One more thing I also wants to retrieve the data like IP and Date by using which i have generated the transaction ID.Is it possible??if not is there any other way to generate transaction Id and retrieve data used to create it? – Sameer kumar Apr 19 '16 at 17:36
  • i dont think there's a good way to get the IP address of the machine. Most likely it will be a local address behind a router. Even if you did get the IP it wouldnt be unique, and IP addresses do change. – John Boker Apr 19 '16 at 17:39
  • no I doesn't means that I am tracking the real ip and generating the transaction id accordingly and stores it in Database upon conversion.Now if i need to get the ip provided for generating that transaction id is it possible to get that? – Sameer kumar Apr 19 '16 at 17:41
  • It looks like it may be possible now, but generating a transaction id from an MD5 sum of an IP address probably will have collisions. http://stackoverflow.com/questions/20194722/can-you-get-a-users-local-lan-ip-address-via-javascript – John Boker Apr 19 '16 at 17:45
  • this is ideal, but not moral. users have the same fingerprint on both normal and incognito browsers (meaning users can be tracked even if they dont want to be tracked). – quiquelhappy Nov 13 '20 at 10:47
0

Another possible way.

echo getenv("username");

The username used in windows.
But cookie is better as suggested earlier

Andreas
  • 23,610
  • 6
  • 30
  • 62