Is it possible to track user before login?


I am building a recommendation plateform. The aim of the platform is to recommend stuff using a link ( or customize link ). What i want to do :

  1. When user visit our site the first time through a recommendation link (, i set a cookie ( or a user id with piwik). I have to be able to create the id because i want to use link information ( ex: 563535355353)
  2. When the user the user register i have to check if there is a set id so i can know which user recommend first the platform to the registered user.

Is this possible with Piwik ?
I use : Java, Spring, AngularJS, Javascript and HTML5 as languages.

Thanks for giving me some ideas.