You could use localStorage to store data client-side.
localStorage.setItem("bar", foo);
var x = localStorage.getItem("bar");
Works kind of like cookies but there are also risks involved. I'd advice you to research it a little, starting for example here
You can basically store everything in it, for example your referring URL.
EDIT @comment:
to clear the whole storage you can use:
localStorage.clear();
and to clear a certain key/value pair: localStorage.removeItem(key)
in terms of compatibility:
caniuse.com is pretty decent.