Does every Jew know his tribe? I heard that every Jew has the name of his tribe written somewhere inside of his hat that he is wearing. Is it true?
No, and no. The only thing I have written in my hat is my name and number so I can be contacted if I lose it.
In general, Jews today do not know what tribe they are from, with the exception of Levites and Kohanim (Jewish priests). Both come from the tribe of Levi, and anyone who is a Levite or a Kohen has a family tradition that they indeed come from the tribe of Levi.
I think that this question might be a duplicate of Are there any Jewish people alive today who can identify themselves as coming from a particular tribe?. Yaakov Ellis' answer over there covers this and more.