javascript to create unique id for each device


It is not easy to create Unique Identification Number for the visitors who visiting your website or blog. Most of the web developers will use IP Address to identify the users and track them. They use the IP address for tracking return visitors and unique visitors etc. IP address of the user will change according to their network. So, We need something that create an Unique ID for each visitors who visits our website.

Demo Click here Download Click here

How to Create Unique ID Using Javascript:

The java-script code that I displayed below will create the Unique Id for a device. When a user visit your website or app, this script will run and grab some browser details for creating unique identification number. The identification number can be displayed or store to your database as per your wish.
var navigator_info = window.navigator;
var screen_info = window.screen;
var uid = navigator_info.mimeTypes.length;
uid += navigator_info.userAgent.replace(/\D+/g, '');
uid += navigator_info.plugins.length;
uid += screen_info.height || '';
uid += screen_info.width || '';
uid += screen_info.pixelDepth || '';
The above script will generate UID and store it variable uid. The stored UID will be displayed using the "document.write(uid);". You can use the UID variable to store the Unique Identification Number to your database or cookie.
You can use the script to track Unique and Returning visitors. You can also use the script to create unique affiliation links and track. The script will be more powerful if you use JavaScript Cookie with it.

Suggested Articles for Webmasters:

Thanks for reading this article. If you enjoyed this article, Please write your comments also share this article with your friends.Thanks again.