If you're transferring to another international flight, you don't have to go through immigration/customs, just a security check.
There's a point at which passengers who are staying in Japan and passengers who are going directly to another country split off. It's clearly marked.