The device ID uses browser local storage, but there is a know issue with ios devices clearing it occasionally: https://stackoverflow.com/questions/15114571/is-localstorage-on-ipad-safari-guaranteed-to-be-persistent
If no deviceID is found, a new random one is generated. Unfortunately, to my knowledge there’s no better way to do it because in general browser users don’t want their browsers/computers to be uniquely identifiable.