Google analytics only for anonymouse users

I’m using ghost 3.x on a self-hosted installation.
I’m using google analytics for stats, adding the classic google code in code injection settings.
Is there a way to do not track if a user is logged?

Thanks!