How do I transfer anonymous data the user when he registers?
In fact it turned out to be simple (after spending a long time trying to be clever). 

In hook_form_user_register_form_alter() add a value field to the form... 

$form['mydata'] = array( 
  '#type' =&gt; 'value', 
  '#value' =&gt; $mydata, 
  // in any form you like 
); 


Then in hook_user_insert() that data is in the $edit array, and already added to the $account object. Make sure you unset it from the $edit array otherwise it'll get put into the 'data' field. Anyway by this point the $account has a uid so it's possible to save the data.