Question: What is the Japanese expression for:

> 
> Sorry, I wasn't listening
> 
> 
> 

For example, for when you're asked a question and realize that you have no idea what it's about as you've been thinking about something else instead of listening to your collocutor.

Answer: 
It all depends, of course.

If you just want a translation of "Sorry, I wasn't listening" then there is

> 
> ごめんなさい、聞いていませんでした。
> 
> 
> 

But if someone is explaining something to you, I might sidestep to

> 
> ごめんなさい、もう一回説明してくれますか  
> 
>  Sorry, could you repeat that (explanation)?  
> 
>  Sorry, could you explain that again?
> 
> 
> 

even in English.

More often than one might think, however, the issue of not listening to someone is avoided completely with

> 
> あ、そうですか。
> 
> 
> 

if the situation suggests you should express mild surprise or doubt, or

> 
> そうですね。
> 
> 
> 

if the situation suggests you should just agree with whatever your collocutor said. Of course the Japanese do value people who listen to them, but they are much more forgiving to people who nod in agreement, even though they have evidently no idea what has been said. In certain contexts, making the speaker repeat right there and then (which you certainly would imply by saying "I wasn't listening") may be rude and the more polite thing would be to just let it be, until it is apparent that you didn't understand. Then, if your collocutor would be so kind as to tell you again, you should make it clear that you are willing to try to listen once again.

A bit more context would certainly help make this answer more specific.
I think you could say...  

●ごめん、聞いてなかった。 / ごめん、なんて？/ ごめん、もう一回。 to your friend/family.  

●すいません、聞いてませんでした。/ すいません、もう一回お願いします。 to your teacher / in class.  

●すみません/申し訳ございません、もう一度お願いします/もう一回お願いします/もう一度お願いできますか。 to your boss / in a business meeting.